我想验证哈希密码,但是即使密码正确,它也始终返回false
我表中的列是密码varchar(255),输出哈希为25d55ad283aa400af464c76d713c07ad
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
session_start();
include('config.php');
// if($_SERVER["REQUEST_METHOD"] == "POST") {
// email and password sent from form
if (isset($_POST['email'])) {
//do something
$email = $_POST['email'];
//$password = $_POST['password'];
}
if (isset($_POST['password'])) {
$password = $_POST['password'];
//$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
}
$conn= new mysqli ("$DB_HOST", "$DB_USER", "$DB_PASSWORD","$DB_NAME");
$db="ship2two4_a53";
$sql = "SELECT email,password FROM usersdb WHERE email = '$email' ";
mysqli_select_db($conn,$db);
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
//$active = $row['active'];
$count = mysqli_num_rows($result);
$array = array_values($row);
//print_r($array);
$psw2= $array[1];
echo $psw2;
echo $password;
if(password_verify($_POST['password'], $psw2))
{
echo "true";
}
else{
echo "false";
}
// If result matched $email and $password, table row must be 1 row
if($count==1) {
// session_register("email");
$_SESSION['email'] = $email;
}
//header("Location: ../sbAdmin/index.php");
mysqli_close($conn);
?>
我希望验证密码,然后将用户重定向到仪表板,但始终显示为假