密码从html到php然后mysql
我有一个注册页面,其中包含以下密码输入控件:
<input type="password" />
将此密码发送到服务器然后将其保存到数据库中以便稍后登录时进行比较的最佳方式是什么?
I have a registration page which has the following password entry control:
<input type="password" />
What is the best way to send this password to the server and then save it into a database for later comparison when login in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如@Elzo建议的,当涉及密码和隐私数据时必须使用HTTPS。 HTTPS 对于网络数据传输很有用。现在,关于密码存储安全性...密码必须使用单向哈希算法(如 md5)保存(您可以使用 php 中的 md5() 函数)。不要在数据库中存储干净的密码。然后,当用户登录时,服务器端脚本将接收密码,并检查用户通过html表单发送的md5(“userpasswordinput”)与存储在db表中的值(之前编码为md5)。
As @Elzo suggested, HTTPS must be used when passwords and privacy data are involved. HTTPS is useful for network data transmissions. Now, about password storange security... the password must be saved using oneway hashing algorithm like md5 (you can use the md5() function in php). Don't store clean passwords in the db. Then, when the user will log in, the server side script will receive the password and it will check the corrispondence between the md5("userpasswordinput") sended by user through the html form and the value stored in the db table (previosly encoded as md5).
最好的方法是使用HTTPS。 HTTPS 保护从客户端到服务器的流量,并且是专门为此设计的。您不需要在此级别对任何内容进行编码。 @Adrian 链接帖子是关于在数据库中存储密码的,您将在那里获得有用的信息。请记住不要直接保存密码,而是保存哈希值或高度加密的版本。
The best way is to use HTTPS. HTTPS protects traffic from client to server and was designed specifically for this. You dont need to encode anything at this level. @Adrian link post is about storage of the passwords in a database and you will get there useful info. Just remember not to save the passwords directly, save either hashes either heavily encrypted versions.
请参阅此处的答案:
在 PHP 中对密码进行编码的最佳方法
See this answer here:
Best way to encode passwords in PHP