password_verify()不使用数据库

时间:2016-10-18 12:55:57

标签: php

我的注册页面是

if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];

$select_pass_query = "SELECT `password` FROM `company_login` WHERE `user_name` = '".mysqli_real_escape_string($db_connect,$username)."'";
if ($select_pass_query_run = mysqli_query($db_connect,$select_pass_query)) {
    // echo "suceessfully find the password";

    $pass_num_row = mysqli_num_rows($select_pass_query_run);

        if ($pass_num_row==NULL) {
            echo "Invalid username/password combination";
        } else if ($pass_num_row==1) {

            $user_password = mysqli_fetch_row($select_pass_query_run);

            $user_password_result = $user_password[0];
            echo $user_password_result . "<br/>";
            echo $pass_verify = password_verify($password, $user_password_result);

        } else {
            echo 'failed';
        }


} else {
    echo 'cannot find the password';
}

我正在尝试使用以下代码从数据库中获取值:

$user_password_result

当我回显出$pass_verify = password_verify($password, $user_password_result);变量时,它会显示,因此数据库成功返回值,但当我回显JavaFX时,不会显示任何内容。为什么会这样?

1 个答案:

答案 0 :(得分:2)

password_verify返回一个布尔值。

如果登录无效,则回显假值将不会打印任何内容。