Reputation: 63
Thanks for helping me on this question. I am trying to compare the passwords with php password_verify but it is not working. Is there something wrong with my code? (i get the second message 'INVALID USER OR PASSWORD') Cheers!
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(); }
Upvotes: 0
Views: 901
Reputation: 63
Thanks for helping guys! The problem was in the DB column length, it wasn't long enough for the hash. Thank you!
Upvotes: 2