Password_verify bcrypt不工作

时间:2015-06-02 14:16:23

标签: php passwords prepared-statement

感谢您帮我解决这个问题。我试图用php password_verify比较密码,但它无法正常工作。我的代码有问题吗? (我得到第二条消息'无效用户或密码')干杯!

function login_aut($uname, $pass){

     include('_con.php');
     include('password.php');

    $stmt = $conex->prepare("SELECT id, pass FROM tb_users WHERE uname =?");

    /* bind parameters for markers */
    $stmt->bind_param("s", $uname);

    /* execute query */
    $stmt->execute();

    /* get num of rows */
    $stmt->store_result();
    $numrows = $stmt->num_rows;

    if(($numrows) == ""){echo 'INVALID USER ';die();}

    $stmt->bind_result($u_id,$upass);

    $stmt->fetch();
    /* close statement */
    $stmt->close();



if (!password_verify($pass,$upass)) { echo 'INVALID USER OR PASSWORD'; die(); }

1 个答案:

答案 0 :(得分:2)

感谢您的帮助!问题出在DB列长度上,它对于散列来说不够长。谢谢!