从数据库中获取哈希后,Password_hash函数在PHP中不起作用

时间:2018-06-25 13:25:40

标签: php mysqli

image of the database

structure of database

我正在尝试使用password_hash函数,但不知道哪里出了问题 每当我点击正确的凭据时,它都会说无效的凭据

php代码:filename:verify.php

<?php   
    $con = mysqli_connect('localhost','root','','notification');

        if($con == FALSE)
        {
            echo "connection is not done";
        }

    if(isset($_POST['submit']))
    {                                   
        $inputmail = $_POST['email'];
        $inputpass = $_POST['password'];

        }
    $qry = "SELECT * FROM `users` WHERE username = '$inputmail'";           
    $result = mysqli_query($con,$qry);
    $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
    if (password_verify($inputpass, $row['password'])) {
    echo "Success!";
}
else {
    echo "Invalid credentials";
}?>

html代码:

<!DOCTYPE>
<html>
<body>
  <form action="verify.php" method="post" id="login-form">
    <input type="text" name="email" placeholder="Email ID" required>
    <input type="password" name="password" placeholder="Password" required>
    <input type="submit" name="submit" class="login login-submit" value="Login">
  </form>
 </body>
</html>

0 个答案:

没有答案