1. User authentication
Verify that the user name is a registered member. The database user table is generally validated with Ajax.
The AJAX code is as follows:
$('[Name=cpname]'). blur (function () {varRe =/^\w{6, A}$/; if(Re.test ($ ( This). Val ())) {//Ajax Connection Database validation$.ajax ({URL:'cp/check_cpname/cpname/'+$('[Name=cpname]'). Val (), type:'Get', Success:function ($msg) {if($msg = =0) {Check_cpname=true; $('[Name=cpname]'). Next (). HTML ('<font color= "Red" >x</font>'); }Else{check_cpname=false; $('[Name=cpname]'). Next (). HTML ('<font color= "Red" >√</font>'); } } }); }Else{ $( This). Next (). HTML ('<font color= "Red" >x</font>'); } });
Verification Code Customization
2. Email Verification :
As in step 1, verify that the user entered the mailbox as a registered bound mailbox.
3. Send mail:
This step uses the Phpmailer component. Go to the online search for phpmailer components download.
Place the following two class libraries into the catalog of the project components:
Class.mailer.php class.smtp.php ( mostly SMTP protocol, if POP3 protocol, it is class.pop3.php)
Message Configuration method:
Public functionSendMail$to,$subject,$content){ include_once(‘class. Phpmailer.php '); $mail=NewPhpmailer (); $mail-issmtp (); $mail->smtpauth =true; $mail->ishtml (true); $mail->charset = "UTF-8"; $mail->encoding = "Base64"; $mail->addaddress ($to, ""); $mail->subject =$subject; $mail->body =$content; $mail->port = 25; //The following 5 variable values must be modified in a truthful $host= ' smtp.ym.163.com ';//NetEase's Enterprise mailbox $username= ";//Real Email address $password= ";//Real Password $from= ";//Email from Sender $fromname= ";//Sender name//$mail->addreplyto ("", ""); $mail->addattachment ("ok.jpg"); Accessories//The following settings-do not change! $mail->host =$host; $mail->username =$username; $mail->password =$password; $mail->from =$from; $mail->fromname =$fromname; //send and return the appropriate information return $mail-Send (); }
How to send mail:
Public functionDoemail () {$email=Trim($_post[' Email ']); $to=$email; $subject= ' Retrieve password '; $code=Rand(100000,999999);//six-bit random number, password $_session[' CODE ']=$code;//Deposit Session $contents="; $content. = ' <li style= ' width:500px; Float:left; "> Congratulations! To retrieve the password successfully, please enter the password within 30 minutes. </li> '; $content. = ' <li style= ' width:1000px; Float:left; " > Retrieve Password code: '; $content. = ' <span style= ' color: #F00; " > '; $content.=$code; $content. = "</li>"; if($this->sendmail ($to,$subject,$content)) { $_session[' Sendtime ']= Time(); Record Send time
//Skip to Password verification page}Else{ Echo' Message failed to send, please try again! ‘; //jump back to the mailbox verification page }}
4. Password verification:
Public functiondosafepwdsuccess () {$code=$_post[' Code ']; if($code= = "'){ Echo' password is empty '; //jump to the original page}Else{ if( Time()-$_session[' Sendtime '] <1800) {//Verify that the password expires, this is 30 minutes effective time if($code==$_session[' CODE ']) {//Verify Password $_session[' CODE ']=Rand(100000,999999);//Verify that the original password expires//jumps to the Reset Password page immediately after verification}Else{ Echo' Password is incorrect or you have verified this password! ‘; //jump to the original page } }Else{ Echo' Sorry, the password is invalid, please resend the message! ‘; //Jump Mail Send page } } }
5. Reset Password
There's nothing to say about this. Reset the new password is OK.
Phpmail e-mail (Website recovery password Module development)