I'm trying to check if a password is correct. The password is in a database and hashed. Im sure that the connection to the database works, because other querys where no problem. So my problem is, that it allways returns $password == false, also when the password should be right.
Here my code:
public function checkOldPwd($user_name, $pwd) {
$query = "SELECT 'user_pwd' FROM users WHERE user_name = ?";
$statement = ConnectionHandler::getConnection()->prepare($query);
$statement->bind_param('s', $user_name);
$statement->execute();
$result = $statement->get_result();
if(!$result) {
throw new Exception($statement->error);
}
if (password_verify($pwd, $result)) {
$password = true;
}else{
$password = false;
}
$result->close();
return $password;
}
I hope you can help me.