gpt4 book ai didi

php - password_hash() 不工作

转载 作者:行者123 更新时间:2023-11-29 05:13:56 24 4
gpt4 key购买 nike

<分区>

任何人都可以指导我哪里做错了。密码散列工作正常并存储在我的数据库中但是当我尝试使用像 (123) 这样的真实密码登录时,它没有让我登录。谢谢!

    <?php
// registration script
if (isset($_POST['submit'])) {

$user_name = $_POST['username'];
$user_email = $_POST['email'];
$user_pass = $_POST['password'];

$query = "SELECT * FROM users where Email = '" . $_POST["email"] . "'";
$result = $obj->run_query($query);

if ($count = mysqli_num_rows($result) == 0) {

$query = "INSERT INTO users (Name, Email, Pass) VALUES('" . $user_name . "', '" . $user_email . "', '" . password_hash($user_pass, PASSWORD_DEFAULT) . "')";
$result = $obj->run_query($query);

echo "<script>alert('You have successfully Registered!')</script>";
echo "<script>window.open('welcome.php','_self')</script>";

} else {

echo "<script>alert('This user email $user_email is already exist!')</script>";
}
}

// login script
if (isset($_POST['login'])) {

$name = $_POST['name'];
$email = $_POST['email'];
$password = password_hash($_POST['pass'], PASSWORD_DEFAULT);


$query = "SELECT * FROM users WHERE Email = '$email' AND Pass = '$password'";
$result = $obj->run_query($query);

if ($count = mysqli_num_rows($result) > 0) {

$_SESSION['email'] = $email;
$_SESSION['name'] = $name;

echo "<script>window.open('welcome.php','_self')</script>";

} else

{
echo "<script>alert('Your email or password is incorrect!')</script>";
}

}

?>

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