为什么password_verify在为true时返回false

时间:2017-11-24 07:31:43

标签: php mysql

<?php
$server_host = "mysql-omarsdajani.alwaysdata.net";
$server_username =  "usertestsest";
$server_password = "testtest";
$server_dbName = "omarsdajani_hustlehut";

$player_email = $_POST ["emailPost"];
$player_password = $_POST ["passwordPost"];

$conn = mysqli_connect ($server_host, $server_username, $server_password, $server_dbName);

if (!$conn) {
    echo ("Could not connect to the server.");
}

$findPlayer = mysqli_query ($conn, "SELECT * FROM Users WHERE Email = '$player_email'");

if (mysqli_num_rows ($findPlayer) > 0) {
    while ($row = mysqli_fetch_assoc ($findPlayer)) {
        if (password_verify ($player_password, $row['Password'])) {
            echo ("Signed in");
            echo ("|ID:" . $row['ID'] . "|Email:" . $row['Email'] . "|Username:" . $row['Username'] . "|Name:" . $row['Name'] . "|Date Registered:" 
            . $row['Date_Registered'] . "|Goal:" . $row['Goal'] . "|System:" . $row ['System'] . "|Starting BFP:" . $row ['Starting_BFP'] . 
            "|Starting Weight:" . $row ['Starting_Weight'] . "|Cal Goal:" . $row ['Cal_Goal'] . "|Carb Goal:" . $row ['Carb_Goal'] . 
            "|Protein Goal:" . $row ['Protein_Goal'] . "|Fat Goal:" . $row ['Fat_Goal'] . "|Current Carbs:" . $row ['Current_Carb'] . 
            "|Current Protein:" . $row ['Current_Protein'] . "|Current Fat:" . $row ['Current_Fat'] . "|Current Cals:" . $row ['Current_Cals'] 
            . "|Current BFP:" . $row ['Current_BFP'] . "|Current Weight:" . $row ['Current_Weight']);
        } else {
            echo ("Incorrect password");
        }
    }
} else {
    echo ("Incorrect email");
}

以上是我的PHP登录脚本,密码不会验证。我回显了$ player_password,并且从POST输入的密码是正确的。问题是密码无法验证。在我的数据库中,Password列的列长度为600个字符。老实说,我不知道这里有什么问题。

0 个答案:

没有答案