The variable $submitErr = ‘Your login credentials are incorrect’; is not getting set in the code below. I get redirected to the correct page if the correct username and password is set, but the variable is not set if the password is incorrect. Any ideas why?
Thanks a lot for any help you can offer.
<?php
include("config_test.inc");
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$myusername = mysqli_real_escape_string($db,$_POST['username']);
$mypassword = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT password FROM molmed_members WHERE login = '$myusername'";
$result = mysqli_query($db,$sql);
if (!$result) {
printf("Error: %s\n", mysqli_connect_error());
exit();
}
if (mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if (password_verify($mypassword, $row[0]))
{
session_start();
$_SESSION['login_user'] = $myusername;
header("location: welcome_test.php");
} else {
$submitErr = 'Your login credentials are incorrect';
}
}
}
?>