识别表单文本输入电子邮件地址并发送电子邮件,无需服务器处理

时间:2018-03-22 23:18:33

标签: javascript html forms

我目前正在大学学习网络开发,我的课程的一部分是为一家销售手机的移动公司创建一个网站,并在网上销售。

我正在尝试创建一个登录和注册表单,但目前正努力让我的表单识别并使用用户输入的电子邮件向他们发送电子邮件,验证他们已提交是否可能,如果有的话,任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

What I will suggest is in your server backend, whether it be PHP, NodeJS, etc that you register the user in your database and have a boolean value named

'validated' true|false

set default to false, also generate a unique hash and assign it to that user under something like

'validate_hash':gnOOBhgenl2g432noug24g42

Use whatever function your backend server provides (or a library) to generate a unique has, and save this to the newly registered user

Then use a mail function to email the user with a link that will 'verify' them, by adding the unique has to a post url like this:

example.com/register/verify?hash=gnOOBhgenl2g432noug24g42&email=example@mail.com

Obviously you will have to create a script at that location and handles the link and checks the hash value given against the mail provided in the database If the hash value matches, you can update the users status to

'verified'true

And they can now access services normally.

Majority of this wont need fancy outside libs or complicated coding, just follow what I suggested and google the things I mentioned if you need to figure out a particular element, or comment/msg me!