I see that you store the password hash in the database, but for other readers, never store passwords in plain text in the database. You do not want to be like Monster.com.uk !
, MD5(). SHA256. - PHP hash().
salt. . rainbow table.
mysqli mysql. Mysqli , SQL-.
. , :
$input_login = $_POST['login'];
$input_password = $_POST['password'];
$stmt = $mysqli->prepare("SELECT password, salt FROM customer WHERE login = ?");
$stmt->bind_param("s", $input_login);
$stmt->execute();
$stmt->bind_result($password_hash, $salt);
while ($stmt->fetch()) {
$input_password_hash = hash('sha256', $input_password . $salt);
if ($input_password_hash == $password_hash) {
return true;
}
}
$stmt->close();
return false;
, login = ? AND password = ?, . , , , - , .
, , , , .
@Javier , ( ) . .
MD5() PHP- - . . , , PHP.
PHP . , , . SQL-, , , . , !
, - PHP, ( PHP-), .