哈希密码不是从数据库验证

时间:2019-07-11 14:49:14

标签: php mysqli

我在从数据库验证密码时遇到问题,我使用的是password_hash($ password,Password_Default);

<?php

session_start();

include ("connection.php");

$msg1= "";

if(isset($_POST['email'])){

    $email = $_POST['email'];
    $password = $_POST['password'];

    $sql="SELECT id,password from item_master_login where email 
    ='".$email."' ";
    $result = mysqli_query($conn,$sql);
        if(mysqli_num_rows($result)>0){
        $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
        $passwordhash = $row['password'];
        if(password_verify($password,$passwordhash)){
            header('location:index.php');
        }
        else{
            $msg1 = "failed";
        }
    }

    else{
        $msg1 = "email issue";
    }

}

?>

0 个答案:

没有答案