Php+ajax Change Password issues

Source: Internet
Author: User
Other errors can be interpreted, the new password and duplicate password whether it is not consistent, will start the countdown to send the verification code, do not know what the reason?

This is the JS code
/**
* TPL/CHANGE_PWD Verification Get 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 ("* Initial password cannot be null");
Form_pwd.oldpwd.focus ();
return false;
}else{
$ ("#oldpwd_1"). HTML ("");
}
if (Pwd_val = = "") {
$ ("#pwd_1"). HTML ("* New password cannot be empty");
Form_pwd.pwd.focus ();
return false;
}else{
$ ("#pwd_1"). HTML ("");
}
if (Re_pwd_val = = "") {
$ ("#re_pwd_1"). HTML ("* Duplicate password cannot be null");
Form_pwd.re_pwd.focus ();
return false;
}else{
$ ("#re_pwd_1"). 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 phone (' + nowtime + ') ');
SetInterval ("Setremaintime ()", 1000);
}else{
if (msg = = "Error1") {
$ ("#oldpwd_1"). HTML ("* Raw password input error");
return false;
}else{
$ ("#oldpwd_1"). HTML ("");
}
if (msg = = "Error2") {
$ ("#re_pwd_1"). HTML ("* Two input password inconsistent");
return false;
}else{
$ ("#re_pwd_1"). HTML ("");
}
}
}
});
}

This is the changePwd.inc.php code
Session_Start ();
Include_once (".. /conn/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 have no code to check for new and duplicate passwords

You have no code to check for new and duplicate passwords


Yes, inside the changePwd.inc.php code, if (Strtoupper ($pwd) = = Strtoupper ($re _pwd))

Too long to see the eyes ache
Personally think it's your if judgment is a little 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";}


This side must have written a wrong place, or there is no error when there is no end code, the following time countdown continues to execute the

Too long to see the eyes ache
Personally think it's your if judgment is a little 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";}


This side must have written a wrong place, or there is no error when there is no end code, the following time countdown continues to execute the



No end code at the time of the error

HTML error After you did not stop Ah, it has been carried out.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.