So I have a form
<form id="login_form" method="post" action="login.php">
<input type="text" name="email">
<input type="password" name="pass">
<input type="submit" name="submit" value="Log in" onclick="submitFunction()">
</form>
When the form is submitted I am checking if the username and password are correct
if(isset($_POST['submit'])) {
$email = $_POST['email'];
$pass = $_POST['pass'];
$sql = "SELECT email,password FROM user_details WHERE email='$email' AND password='$pass'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$_SESSION["email"] = $_POST['email'];
}
else {
echo "Incorrect username or password. Please try again!";
}
}
But I also want to load a new page, which I am trying to do via javascript
function submitFunction()
{
window.location.href = "new url";
}
I tried replacing the submit button with just a button however then I can not get my php to execute because I can't use if(isset($_POST['submit'])), but if I use a submit button then I do not know how to call my javascript function because I can't use onclick can I? Any help would be appreciated :)
Also I know I should not just store the password in my database and sql injection and all that but I just want to try and get this to work