Any other errors related to changing the password of php + ajax can be interpreted. no matter whether the new password is the same or not, the new password will start to send the verification code countdown. I don't know why?
This is the js code.
/**
* Tpl/change_pwd verification code
*/
Function getCode_pwd (){
Var oldpwd_val = $ ("# oldpwd"). val ();
Var pwd_val = $ ("# pwd"). val ();
Var re_pwd_val = $ ("# re_pwd"). val ();
If (oldpwd_val = ""){
$ ("# Oldpwd_1" ).html ("* The initial password cannot be blank ");
Form_pwd.oldpwd.focus ();
Return false;
} Else {
$ ("# Oldpwd_1" 2.16.html ("");
}
If (pwd_val = ""){
$ ("# Pwd_1" ).html ("* The new password cannot be blank ");
Form_pwd.pwd.focus ();
Return false;
} Else {
$ ("# Pwd_1" ).html ("");
}
If (re_pwd_val = ""){
$ ("# Re_pwd_1" ).html ("* repeated passwords cannot be blank ");
Form_pwd.re_pwd.focus ();
Return false;
} Else {
$ ("# Re_pwd_1" pai.html ("");
}
$. Ajax ({
Type: "POST ",
Url: "../inc/changePwd. inc. php ",
Data :{
Oldpwd: oldpwd_val,
Pwd: pwd_val,
Re_pwd: re_pwd_val
},
Success: function (msg ){
If (msg = "success "){
NowTime = 30;
$ ('# Ck'). attr ('disabled', true );
$ ('# Ck'). attr ('value', 'View mobile phone ('+ nowTime + ')');
SetInterval ("SetRemainTime ()", 1000 );
} Else {
If (msg = "error1 "){
$ ("# Oldpwd_1" ).html ("* incorrect original password ");
Return false;
} Else {
$ ("# Oldpwd_1" 2.16.html ("");
}
If (msg = "error2 "){
$ ("# Re_pwd_1" ).html ("* inconsistent passwords ");
Return false;
} Else {
$ ("# Re_pwd_1" pai.html ("");
}
}
}
});
}
This is the changePwd. inc. php code.
Session_start ();
Include_once ("../conn. php ");
// Include ("../information/check_interface.php ");
$ Oldpwd = mysql_real_escape_string ($ _ POST ['oldpwd']);
$ Pwd = mysql_real_escape_string ($ _ POST ['pwd']);
$ Re_pwd = mysql_real_escape_string ($ _ POST ['re _ pwd']);
$ User = $ _ SESSION ['user'];
$ Result = mysql_query ("SELECT * FROM tb_admin WHERE admin_user = '$ user' AND admin_pwd =' $ oldpwd '");
If (mysql_num_rows ($ result )! = 0 ){
If (strtoupper ($ pwd) = strtoupper ($ re_pwd )){
$ SQL = mysql_query ("SELECT admin_user, mobile_phone FROM tb_admin WHERE admin_user = '". $ user ."'");
While ($ row = mysql_fetch_array ($ SQL )){
$ Mobile = $ row ['mobile _ phone'];
$ _ SESSION ['mobile'] = $ mobile;
}
Echo "success ";
// Echo postSendMessage ();
} Else {
Echo "error2 ";
}
} Else {
Echo "error1 ";
}
Mysql_close ($ conn );
?>
This is the page code
Reply to discussion (solution)
You do not have the same code to check whether the new password is the same as the duplicate password.
You do not have the same code to check whether the new password is the same as the duplicate password.
Yes, in the changePwd. inc. php code, if (strtoupper ($ pwd) = strtoupper ($ re_pwd ))
Too long, eyes hurt
I personally think that your if statement is a bit messy.
if(mysql_num_rows($result)!=0){if(strtoupper($pwd) == strtoupper($re_pwd)){$sql=mysql_query("SELECT admin_user,mobile_phone FROM tb_admin WHERE admin_user = '" . $user . "'");while($row=mysql_fetch_array($sql)){ $mobile = $row['mobile_phone'];$_SESSION['mobile'] = $mobile;}echo "success";//echo postSendMessage();}else{echo "error2";}}else{echo "error1";}
There must be something wrong, or the code is not completed when no error is reported, and the countdown to the next time will continue to be executed.
Too long, eyes hurt
I personally think that your if statement is a bit messy.
if(mysql_num_rows($result)!=0){if(strtoupper($pwd) == strtoupper($re_pwd)){$sql=mysql_query("SELECT admin_user,mobile_phone FROM tb_admin WHERE admin_user = '" . $user . "'");while($row=mysql_fetch_array($sql)){ $mobile = $row['mobile_phone'];$_SESSION['mobile'] = $mobile;}echo "success";//echo postSendMessage();}else{echo "error2";}}else{echo "error1";}
There must be something wrong, or the code is not completed when no error is reported, and the countdown to the next time will continue to be executed.
No end code when an error is reported
After an error is reported in html, you have not stopped, so you can continue to execute it.