I'm working on a project for school where I need to authenticate users. The code below came from my book but, I can't seem to get it to work. I've checked the query after attempting to bind the values and the query never contains the actual email or password. Can someone tell me what is wrong with my code or what I am doing wrong? I've searched the internet and made sure my code is exactly the same as in my book. Also, I am using the correct credentials.
function is_valid_admin_login($email, $password)
{
global $db;
$password = sha1($password);
$query = 'SELECT adminID FROM administrators
WHERE adminEmail = :email AND adminPassword = :password';
$statement = $db->prepare($query);
$statement->bindValue(':email', $email);
$statement->bindValue(':password', $password);
$statement->execute();
$valid = ($statement->rowCount() == 1);
$statement->closeCursor();
return $valid;
}
When I echo the query after binding the values I always get:
SELECT adminID FROM administrators
WHERE adminEmail = :email AND adminPassword = :password
I would really appreciate the help as I am very new to PHP.