向邮件列表应用程序添加选择退出功能
我想为将收到邮件的客户添加选择退出功能。
我是 php n00b,所以我能想到的最好方法是向他们发送一个表单链接,他们将在其中编写电子邮件,这样我就可以在他们提交时通过查询将其从数据库中取出。
有更优雅的方式吗?我如何通过单击选择退出链接将用户从数据库中删除?
I want to add the opt-out function to the clients who will receive the mails.
I'm a php n00b, so the best way I could figure is to send them a link to a form, where they will write their email, so I can take it out of the database via a query when they submit it.
Is there a more elegant way? How can I take the user out of the database by him simply clicking on the opt-out link?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类似以下内容的内容应该足够简单且安全。
向用户发送一个带有查询字符串的链接,其中包含他们的电子邮件(或者更好的是,如果您生成电子邮件 ID)和他们的电子邮件的加盐哈希值。当用户单击链接时,脚本可以使用电子邮件和盐来验证特定电子邮件,然后将其从数据库中删除。
对电子邮件(或电子邮件 ID)使用盐的原因是这样人们就无法使用带有猜测电子邮件的链接来尝试清除它们。
Something along the lines of the following should be simple and secure enough.
Send a link to the user with a query string that contains their email (or better, email ID if you generate them) and a salted hash of their email. When the user clicks the link, the script can use the email and salt to verify the particular email and then delete it from the DB.
The reason to use a salt with the email (or email ID) is so that people can't use the link with guessed emails to try and wipe them out.