I
I
Ilya Famin2021-06-18 18:30:46
PHP
Ilya Famin, 2021-06-18 18:30:46

Why doesn't password_verify work?

$AuthUserData = [
    'authEmail' => $_POST['authEmail'],
    'authPass' => $_POST['authPass'],
    'authCodeWord' => $_POST['authCodeWord']
];

$AuthUserEmail = $AuthUserData['authEmail'];

$authUserRequest = $DBC->query("SELECT * FROM `users` WHERE `email` = '$AuthUserEmail'");
$countAuthUser = $authUserRequest->rowCount();
$authUser = $authUserRequest->fetch();
if ($countAuthUser > 0 && password_verify($AuthUserData['authPass'], $authUser['passHash'])) {
    echo 'Авторизация прошла успешно!';
    $_SESSION = [
        $authUser
    ];
} else {
    echo 'Авторизация прошла хреново!';
}

When viewing the variables and through everything is correct and the passwords seem to be the same (if you unhash the one that is already in the database), even when you try to display the result of the execution, nothing happens $authUser['passHash']$AuthUserData['authPass']print_f()password_verify

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question