简体   繁体   English

我的密码验证数据库中的值总是返回 false

[英]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.它包含多个$ s,因此它将它们视为字符串中的另一个变量。 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.正如您在评论中所说,您将密码存储在 mac 长度为 10 的列中。如果您阅读password_hash function 的文档,您将看到列长度至少需要 72 个字符。

So changing the max length of your column will probably solve your problem因此,更改列的最大长度可能会解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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