Цель состоит в том, чтобы получить рабочий журнал в коде на 2020 год. PHP версия 7.0 или выше. Пользователь уже зарегистрирован в базе данных и подтвержден активным = 5. Пароль будет использовать ha sh PASSWORD_ARGON2ID.
PDO / PHP Код
error_reporting(E_ALL); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
session_start();
require '../../DBConnections';
$email = trim($_POST["Email"]);
$pass = ($_POST["Password"]);
/* Check if the user email is valid.*/
$sql = "SELECT * FROM Tester WHERE Email= :email";
$stmt = $pdo->prepare($sql);
$stmt->execute(['email'=>$email]);
$stmt->fetch();
if ($email === 0)
{
header("location: https://Failed url");
$pdo=null;
die();
}
/* Look for the account in the db. Note: the account must be active (active = 5) */
$query = 'SELECT * FROM Tester WHERE (Email = :email) AND (active = 5)';
/* Values array for PDO */
$values = array(':email' => $email);
$res = $pdo->prepare($query);
$res->execute($values);
$row = $res->fetch(PDO::FETCH_ASSOC);
/* If there is a result, we must check if the password matches using password_verify() */
if (is_array($row))
{
if (password_verify($pass, $row['Password']))
{
/* Authentication succeeded. Set the class properties (id and name) */
/* Finally, Return TRUE */
header("location: https://Go to Secure url");
$pdo=null;
die();
}
}
/* If we are here, it means the authentication failed: */
header("location: https://Failed url");
$pdo=null;
die();
}
Я получаю нет ошибок, но в нем говорится, что пароль недействителен и нуждается в помощи о том, как это исправить или идеалы о том, как его улучшить.