通过PHP中的电子邮件验证用户 [英] verify a user via e-mail in PHP
问题描述
与某些网站一样,当您注册时,会通过确认链接向您发送一封电子邮件。如何在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屋!