I can't get the value of a variable inside a while loop. Here's my code:
function checkLogin($username, $password) {
global $dbh;
global $queryPassword;
$query2 = $dbh->query("SELECT * FROM employee_accounts WHERE username='$username' AND `password`='$password'; ");
$query2 ->setFetchMode(PDO::FETCH_ASSOC);
while($row=$query2->fetch()) {
$queryUsername = $row['username'];
$queryPassword = $row['password'];
}
if(password_verify($password, $queryPassword)) {
echo '<script>alert("Success ");
windows: location="../../index.php";</script>';
} else {
echo '<script>alert("fail ");
windows: location="../../index.php?v='.$queryPassword.'";</script>';
}
}
When I put the $queryPassword in the url, the value is empty. Your suggestions and solutions will be very helpful. Thank you.