简体   繁体   English

在php中使用md5创建密码时出错

[英]Error while creating password with md5 in php

I have created an admin table and login panel for admin in my website. 我已经在我的网站中为管理员创建了一个管理表和登录面板。 i inserted the data into admin table like 我将数据插入到管理表中

insert into admin values('admin',md5('admin123'))

the values got added and the password was added in the encrypted format. 添加值,并以加密格式添加密码。

But when i try to login to my admin panel its showing 但是当我尝试登录到管理面板时,显示

incorrect password 密码错误

what could be the issue? 可能是什么问题?

you can change links below for using php hash methods; 您可以在下面更改链接以使用php hash方法;

https://secure.php.net/manual/en/function.password-verify.php https://secure.php.net/manual/en/function.password-hash.php https://secure.php.net/manual/en/function.password-verify.php https://secure.php.net/manual/en/function.password-hash.php

with using 与使用

string password_hash ( string $password , int $algo [, array $options ] )

method u can hash your password, and pass it to your database with hashed. 方法您可以对您的密码进行哈希处理,然后将其与哈希值一起传递给您的数据库。 There are different kinds of hash methods changed by your parameters like PASSWORD_DEFAULT, PASSWORD_BCRYPT, PASSWORD_ARGON2I 您的参数(例如PASSWORD_DEFAULT,PASSWORD_BCRYPT,PASSWORD_ARGON2I)更改了多种哈希方法

Then you can use 那你可以用

bool password_verify ( string $password , string $hash )

method for verify your password which came from form with your hash that include your database 验证密码的方法,该密码来自包含数据库的哈希表

 $new=md5('admin123');
 $query=mysqli_query($conn,"insert into admin values('admin','$new')");

Try this code 试试这个代码

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

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