gpt4 book ai didi

php - password_verify 返回 false

转载 作者:行者123 更新时间:2023-12-01 00:37:01 26 4
gpt4 key购买 nike

<分区>

$query = "SELECT * FROM users WHERE username = '$username'";
$query_run = mysqli_query($con, $query);

if(mysqli_num_rows($query_run) < 1)
{
header("Location: ../index.php?login=username");
exit();
}
else
{
if($row = mysqli_fetch_assoc($query_run))
{
//deshashing password
$hashedPwdCheck = password_verify($password, $row['password']);
if($hashedPwdCheck == false)
{
header("Location: ../index.php?login=false");
exit();
}
elseif($hashedPwdCheck == true)
{
//login the user here
$_SESSION ['u_name'] = $row['username'];
$_SESSION ['u_email'] = $row['email'];
$_SESSION ['u_password'] = $row['password'];
$_SESSION ['u_id'] = $row['userid'];

header("Location: ../index.php?login=success");
exit();

上面是登录码。

下面是存储密码并对其进行哈希处理的注册码。

                    else
{
//hashing password
$hashedPwd = password_hash($password, PASSWORD_DEFAULT);
//insert the user into the database
$query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$hashedPwd');";
mysqli_query($con, $query);

header("Location: ../register.php?register=success");
exit();
}

请帮忙,我有点困惑为什么这不起作用。

问候,罗斯

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com