简体   繁体   中英

My password_verify for a value from database always return false

include("src/database.php");#this included file works wll
$query=mysqli_query($conn,"SELECT * FROM students limit 1");
$data=mysqli_fetch_assoc($query);
echo "my hased data id ".$data["password"]." and Actual password is 12345678 <br />";

if(password_verify("12345678",$data["password"])){
    echo "Finnally this worked";
}else{
    echo "THIS ALWAYS EXECUTES";
}

#now i cannot hardcode the data it sees it as a varaible inside of a string since it contains multiple $s
#this is the hashed data $2y$10$S/HjSwqh8QIjc

Another problem is that I can't hardcode the value into a variable. It conatins multiple $ s so it sees them as another variable in a string. What should I do about this?

As you said in the comments you store the password in a column with a mac length of 10. If you read the documentation of the password_hash function you will see the column length need to be at least 72 characters long.

So changing the max length of your column will probably solve your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM