简体   繁体   English

根据状态向用户发送电子邮件

[英]sending an email to the user depending on statusmy

i created a table in the database (mysql),and i write a code for inserting data in the datbase using php.values are inserted properly.here i set the status column value as deactive.when user created in that time ,we send a mail to the user to active the link ,means my site and then status column has to changed as active. 我在数据库(mysql)中创建了一个表,并编写了使用php在datbase中插入数据的代码。正确插入了值。此处将状态列的值设置为deactive。当用户在该时间创建时,我们发送邮寄给用户以激活链接,表示我的网站,然后状态列必须更改为“激活”。

my db table contains the following columns

name,email,pwd,status,lastlogin,security qun,ans

when user is created in that time i set the status as deactive.in that time i want to sent a mail(in this mail,i want to send the link to their account) to the user to active their account ,then only user goes to the next process.after that when user open the mail & click that link,the status column has to changed as active in the database.how can i do this,anyone help me.. 在那段时间创建用户时,我将状态设置为deactive。那段时间我想向用户发送邮件(在此邮件中,我想将链接发送至他们的帐户)以激活其帐户,然后只有该用户到下一个过程。之后,当用户打开邮件并单击该链接时,状态列必须更改为数据库中的活动状态。我该怎么做,任何人都可以帮助我。

You can create column called activation_code , send an email to user with link, which will contain this activation_code . 您可以创建一个名为activation_code的列,并通过链接向用户发送一封电子邮件,其中将包含该activation_code Link like this www.example.com/active.php?activation_code=AABBCCDDEEFF , when user click this link you can get activation_code , find a user at database and change status . 像这样的链接www.example.com/active.php?activation_code=AABBCCDDEEFF ,当用户单击此链接时,您可以获得激活码 ,在数据库中找到用户并更改状态 Also you can create column activation_expires which will contain a date when activation code will expire. 您也可以创建一栏activation_expires ,其中包含激活码到期的日期。

one way to solve the problem is: 解决问题的一种方法是:

  1. make the field 'status' as varchar not int. 使字段“状态”为varchar而不是int。

  2. when you are inserting user information for the first time, make a random string and insert it in the status field. 首次插入用户信息时,请随机输入一个字符串并将其插入状态字段。

  3. say your random string you have created is 'lka342lkjasd8234kl2324ljklj2'. 假设您创建的随机字符串为“ lka342lkjasd8234kl2324ljklj2”。 send the link with the string as a parameter. 发送带有字符串作为参数的链接。

  4. when the link is clicked in the script check the verification string matches the value in your status table. 在脚本中单击链接时,请检查验证字符串是否与您的状态表中的值匹配。

  5. if it matches then show message that his account is verified and change the value of the field to 1 (as 1 indicates a active account) 如果匹配,则显示消息,表明他的帐户已通过验证,并将该字段的值更改为1(因为1表示有效帐户)

  6. if the string doesn't matches then show message the verification link is wrong. 如果字符串不匹配,则显示消息,表明验证链接错误。

in another way you can make another table for storing verification string. 您可以通过另一种方式制作另一个表来存储验证字符串。 and make the status fiend an integer. 并将状态修改为整数。 set 0 initially and make it 1 when verified, and check the verification with the new table. 最初设置为0,验证后设为1,然后使用新表检查验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM