I am trying to "compare" the DB password with the password entered in the html form, but it is not working!
First, the password hash (register.php) was created with the "password_hash". by the way, work perfectly !!!
$conexao = new mysqli($servername, $username, $password, $dbname);
$login = isset($_POST['Login']) ? $_POST['Login'] : '';
$senha = isset($_POST['Senha']) ? $_POST['Senha'] : '';
$crypt_senha = password_hash($senha, PASSWORD_DEFAULT, ['cost' => 18]);
$sql_insert = "INSERT INTO usuarios (Login, Senha) VALUES ('$login','$crypt_senha')";
$conexao -> query($sql_insert) === 0;
echo '<script type = "text/javascript" > alert("data entered successfully!!!") </script>';
The problem is the file "login.php". is not "converting" the password entered with the password that is in the DB!
$conexao = new mysqli($servername, $username, $password, $dbname);
$login = isset($_POST['Login']) ? $_POST['Login'] : '';
$senha = isset($_POST['Senha']) ? $_POST['Senha'] : '';
$sql_auth = "SELECT Login, Senha FROM usuarios where Login = '$login' AND Senha = '$senha'";
$decrypt_senha_DB = password_verify($senha, $sql_auth);
$resultado_auth = $conexao -> query($decrypt_senha_DB);
if ($resultado_auth -> num_rows === 0) {
echo '<script type = "text/javascript" > alert("Incorrect user and/or password!") </script>';
exit();
}
else {
header('location: https://www.google.com.br/');
}
The conclusion is that the registered user can access the platform, even with the wrong password! How can i fix?