通过PHP中的电子邮件验证用户 [英] verify a user via e-mail in PHP

查看:181
本文介绍了通过PHP中的电子邮件验证用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上是使用PHP创建一个Web应用程序,并寻求帮助验证用户。
与某些网站一样,当您注册时,会通过确认链接向您发送一封电子邮件。如何在PHP中实现?
我知道的是,我必须使用PHP mail()函数发送电子邮件。
请帮忙。必要。谢谢。 :)

解决方案

就像使用 CSRF 保护你生成一个独特的令牌。

  $ token = md5 uniqid(rand(),TRUE)); 

您可以在该电子邮件的会话中存储该值,当用户点击电子邮件中的链接(您通过您可以通过查询字符串进行记录),比较两个值。 / p>

为了使其更安全,您可以像CSRF一样添加时间限制。


I'm actually creating a web application using PHP and seek help verifying a user. As with certain websites, when you register, an e-mail is sent to you with a confirmation link. How do I implement that in PHP? All I know is that I have to use the PHP mail() function to send the e-mail. Please help. Necessary. Thanks. :)

解决方案

just like with CSRF protection you generate an unique token.

$token =  md5(uniqid(rand(), TRUE));

You store that value in your session for that email and when the user clicks link in email(you pass token via the query-string) you compare the two values.

To make it more secure you could just as with CSRF add a time-limit.

这篇关于通过PHP中的电子邮件验证用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆