Mobile phone Message verification login, posted out to facilitate later viewing. The required program staff can learn from. Registration is also the logic of this set.
//Foreground code
<ul class= "signlist j_box" style= "Display:none;" > <form method= "POST" > <!--cell phone authentication code login--> <li class= "ITEMBD" ><i class= "user" ></i><input type= "text" name= "mobile" value= "" placeholder= "mobile phone number"/>< /li> <li class= "itembd" ><i class= "pwd" ></i><input "text" type= "code" name= E= "" "Placeholder=" Mobile Authentication Code "/> <a href=" javascript:void (0); "onclick=" U_mobilereg (this); "Class = "Btn_a" > Get Authenticode </a></li> <li><a href= "{: U (' User/findpwd ')}" class= "Blue F_r" ; Forget the password. </a><input type= "checkbox" checked= "Checked" class= "check"/> Remember me </li> <li><
Input type= "button" value= "Login" class= "btn" onclick= "ujdopost (this);" Data-url= "{: U (" User/logins ")}"/></li> </form> </ul>
//js code get Authenticode
function U_mobilereg (self) {
var form = $ (self). Parents (' form '), mobile = Form.find (' input[name= ' mobile] '). Val ();
if ($.zyb.util.empty (mobile)) {
$.zyb.tip ({content: ' Please enter your mobile number ', Icon: ' Error '});
return false;
}
$ (self). Find (' B:eq (1) '). Text (' Submit validation ... ');
$.getjson (Gv.logon, {mobile:mobile}, function (RS) {
if (rs.status = = 1) {
$.zyb.tip ({content:rs.msg});
$ (self). Find (' #J_run_miao '). Text (a);
$ (self). Find (' B:eq (1) '). Text (' Seconds to retry ');
Reset the authentication domain
Ujrunmiao ();
} else {
$.zyb.tip ({content:rs.msg, Icon: ' Alert '}
); return false;
}
//Get Authentication Code controller code
Public Function login_verify () {$mobile = $this->_get (' mobile ', ' trim ');
$bcode = $this->_get (' bcode ', ' trim ');
Form verification if (!is_mobile ($mobile)) {$this->ajaxreturn (0, ' phone format is not correct ');
}//Verify $user = M (' user ')->where (Array (' Mobile ' => $mobile, ' status ' =>1))->find (); ! $user && $this->ajaxreturn (0, ' mobile number does not exist, please register first.
');
The rate already exists and the Generate rule if (M (' msg ')->where (Array (' to ' => $mobile, ' Time ' =>array (' GT ', Time () -60))->count ()) { $this->ajaxreturn (0, ' no time to repeat, please wait a moment.
');
' If (M (' msg ')->where (Array (' to ' => $mobile, ' Time ' =>array (' GT ', Todaytime ()))->count () >10) {
$this->ajaxreturn (0, ' You operate mobile phone too frequently today, please try again tomorrow ');
//Generate random Verification code $code =rand (100000, 999999);
Session (' Mobile_reg ', $code);
$searchs = Array (' {username} ', ' {msg} '); $replaces = Array ($mobile, $code);
$content =c (' zyb_msg_server.template ');
Replace the background template $content =str_replace ($searchs, $replaces, $content);
$data [' content ']= $content;
$data [' Mobile ']= $mobile;
Send SMS $rs =send_http_msg ($data); if ($RS) {//commit once after successful.
Change Validation form field//open Form Validation $md 5reg=md5 (Time (). time ());
Submitting the form requires validating this field session (' Md5reg ', $md 5reg);
Session (' Codes_verifiaction ', Array (' Data ' => $mobile, ' code ' => $code));
$this->ajaxreturn (1, ' CAPTCHA has been successfully sent to your phone! ', $MD 5reg); }else{$this->ajaxreturn (0, ' send failed.
'); }
}
//Submit Login JS code, that is, from form submission, general, submission method is directly in the foreground to write links, the method before the table code has written
Form Post Submit
function Ujdopost (self) {
var form=$ (self). Parents (' form '), webtext=$ (self). Val (), url=$ (self). attr (' Data-url ');;
$.ajax ({
url:url,
data:form.serialize (),
type: "POST",
beforesend:function ()
{
$ (self). Val ("Submitting ...");
},
success:function (RS) {
if (rs.status==2) {
post_tip ({content:rs.msg});
settimeout (function () {
window.location.href=rs.data;
},1500);
return 1;
} if (rs.status = = 1) {
post_tip ({content:rs.msg});
settimeout (function () {window.location.reload ();},2000);
return 1;
} if (Rs.status ==3) {
post_tip ({content:rs.msg});
$ ('. Dialog_box '). Hide ();
$ ('. Dialog_box '). HTML (Rs.data). Show ();
return 1;
} if (Rs.status ==-1) {
alert (rs.msg);
return 1;
} else{
Post_tip ({content:rs.msg,icon: ' alert '});
$ (self). val (webtext);
return 1;}}
,}
);
//Submit Login Code
* * Mobile User Login/Public function logins () {$this->visitor->is_login && $this->redirect (' user/i
Ndex ');
if (is_post) {$type = $this->_request (' type ', ' intval ', 1);
$mobile = $this->_request (' mobile ', ' trim ');
$code = $this->_request (' Code ', ' trim ');
$this->assign (' type ', $type);
$s _temp=session (' codes_verifiaction ');
if ($s _temp[' data ']!= $mobile) {$this->ajaxreturn (0, ' Authentication code information is incorrect ');
} if ($s _temp[' code ']!= $code) {$this->ajaxreturn (0, ' Authentication code error '); }//individual member $uid = M (' user ')->where (Array (' Mobile ' => $mobile, ' Tstatus ' =>1))
; GetField (' id '); if ($mobile &&! $uid) {$this->ajaxreturn (0, ' your login account is not found ');//Confirm Password} $pass
Port = $this->_user_server (); Log in, save session record status $this->visitor->login($UID);
Synchronous Login session (' codes_verifiaction ', null); $this->ajaxreturn (2, ' login succeeded.
','/');
}else{//Open Form Validation $md 5reg=md5 (Time (). time ());
Submitting the form requires validating this field session (' Md5reg ', $md 5reg);
$this->assign (' Md5reg ', $md 5reg);
$this->_config_seo (' title ' => ' member Login '));
$this->display (); }
}
//The following is the definition of code, some of the above definition of the function can not see the understanding of this, of course, I can not put all the definition of the function code are posted.
{/* @todo Member Center configuration JS/} var gv={' login ': ' {: U ("User/login ')} ', {/* Login/} ' logins ': ' {: U (" User/logins ")} ', {/* Mobile login/} ' Telre G ': ' {: U (' user/register ', Array (' type ' =>1)} ', {/* Mobile phone Registration/} ' Emailreg ': ' {: U (' User/register ', Array (' type ' =>2)} ', {* * * mobile phone Registration/} ' MSGV ': ' {: U ("user/msg_verify")} ', {/* Sign up for phone verification Code/} ' logon ': ' {: U ("User/login_verify")} ', {/* Login to get phone verification code * * } ' Resend ': ' {: U ("User/resend ')} ', {/* Register resend Mailbox Activation Code/} ' findpwd_msg ': ' {: U (" User/findpwd "} ', {/* Retrieve password to send activation code/} ' Findpwd_ Msg2 ': ' {: U (' user/findpwd ', Array (' TT ' =>1)} ', {/* Retrieve password Resend activation Code/} ' vfindpwd ': ' {: U (' user/vfindpwd ')} ', {/* Retrieve password Resend Activation Code/} ' Fpwdend ': ' {: U (' User/fpwdreset ')} ', {/* Retrieve password Resend activation Code/} ' Fpwdman ': ' {: U ("User/fpwdman")} ', {/* Manual request retrieve password */} ' account ': ' {: U ("User/account ')} ', {* * * modification of accounts information/} ' bind ': ' {: U (" User/bind_em ')} ', {/* Modify account data to obtain verification code/} ' Bindend ': ' {: U ( "User/bindend")} ', {* * Submit modified account information/} ' GETPRODUCTPJ ': ' {: U ("PRODUCT/GETPJ")} ', {/* Details page Get evaluation content/} ' getcomment ': ' {: U (" Product/getcomment ")} ', {/* Get evaluation details/} ' Addcart ': ' {: U (" Cart/add ")} ', {/* Add shopping cart/} ' submitsalEs ': ' {: U ("User/yservice")} ', {/* Apply for after service/} ' submitcomment ': ' {: U ("User/comment")} ', {* * Submit evaluation Sun/}};