我使用此代码登录并且我已经通过crypt功能存储了我的密码,但是当我验证密码时,它说的密码不正确。 如何验证密码?
<?php
session_start();
include 'connect.php';
$hash = crypt('password');
$passErr = $nameErr = "";
$pass = $name = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["username"]))
{
$nameErr = "Username is required";
}
if (empty($_POST["password"]))
{
$passErr = "Password is required";
}
if (empty($passErr) && empty($nameErr) && isset($_POST['username']))
{
$username = mysqli_real_escape_string($con, $_POST['username']);
$password = mysqli_real_escape_string($con, $_POST['password']);
$sql = "SELECT * FROM users WHERE username='$username' and password='$password' and activation='approved'";
$result = mysqli_query($con, $sql);
$count = mysqli_num_rows($result);
if (password_verify($_POST['password'], $hash))
{
header('Location:test.php');
}
else
{
echo "Incorrect Username/Password";
}
}
}
?>