0
Well, I created a function called search party that should encrypt the user’s password and compare it with the database but every time I run I get the error:
Warning: mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs filename database.php on line 9
Function
function buscaUsuario($conexao, $email, $senha){
$hash = password_hash($senha, PASSWORD_DEFAULT);
$query = "select * from usuarios where email='{$email}, senha='{$hash}'";
$resultado = mysqli_query($conexao, $query);
$usuario = mysqli_fetch_assoc($resultado);
if(password_verify($usuario, $hash)){
echo "Valid";
} else {
echo "invalid";
}
return $usuario;
}
How could I make this function compare the generated Hash with the hash that is in the database and still confirm if the login has been validated or invalid?
I was thinking of having my database return the registered value in the password field assigning it to a variable so I can use the password_verify($user_senha, $hash)
and check if the user generated hash is the same as the one registered in the database. Would it work? If so, how?
The correct thing would be to remove the
AND senha='{$hash}'
, because Bcrypt has a whole salt, which will cause the$hash
always be different.– Inkeliz