password_hash函数在数据库中给出空白结果

时间:2015-12-09 02:29:27

标签: php

我试图让password_hash函数为我新创建的网站工作但在我的数据库中我一直在密码部分得到一个空白的结果,这导致我的帐户没有任何形式的密码所以它不会登录是我在这里做错了,这是我的代码和我的验证码。

<?php

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

        session_start();
        $FName = $_POST['First_Name'];
        $LName = $_POST['Last_Name'];
        $Email = $_POST['Email'];
        $PW = $_POST['Password'];

        $StorePass = password_hash($PW, PASSWORD_BCRYT, array('cost' => 10));

        $sql = $con->query("INSERT INTO `lpg-user-db` (Fname, Lname, Email, Password)Values('{$FName}', '{$LName}', '{$Email}', '{$StorePass}')");

        header('Location: Login.php');
    }
?>

验证码:

<?php

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

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

        $result = $con->query("select * from `lpg-user-db` where Email='$EM'");

        $row = $result->fetch_array(MYSQLI_BOTH);

        if(password_verify($PW, $row['Password'] )) {

        session_start();

        $_SESSION["UserID"] = $row['UserID'];

        header('Location: Account.php');

        }else{
            session_start();
            $_SESSION["LoginFail"] = "Yes";
        }
    }
?>

0 个答案:

没有答案