below is my script to change password. if all data is entered correctly, please wait message comes up but no further processing is received. Please help me in rectifying the error. if i work on this script without javascript, it works fine but with javascript it becomes non-responsive. it is not showing any error too.
<?php
include_once("check_login_status.php");
if(isset($_GET["u"])){
if(isset($_POST["email"])){
include_once("php_includes/db_conx.php");
$email = mysqli_real_escape_string($db_conx, $_POST['email']);
$pass = md5($_POST['pass']);
$pass1 = md5($_POST['pass1']);
$pass2 = md5($_POST['pass2']);
if($email == "" || $pass == ""||$pass1 == ""||$pass2 == ""){
echo "login_failed";
exit();
} else if($pass1 !=$pass2){echo"no match";
exit();}
else
{
// END FORM DATA ERROR HANDLING
$sql = "SELECT id, username, password FROM users WHERE email='$email'";
$query = mysqli_query($db_conx, $sql);
$row = mysqli_fetch_row($query);
$db_id = $row[0];
$db_username = $row[1];
$db_pass_str = $row[2];
if($pass != $db_pass_str){
echo "data wrong";
exit();
} else if($u != $db_username){
echo "username_mismatched";
exit();
}
else {
$sql = "UPDATE users SET password='$pass1' WHERE email='$email'";
$query = mysqli_query($db_conx, $sql);
echo "success";
exit();
}
}
exit();
}}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="js/main.js"></script>
<script src="js/ajax.js"></script>
<script>
function emptyElement(x){
_(x).innerHTML = "";
}
function paschange(){
var email = _("email").value;
var pass = _("pass").value;
var pass1 = _("pass1").value;
var pass2 = _("pass2").value;
if(pass == "" || pass1 == ""||pass2==""||email==""){
_("status").innerHTML = "Fill out all of the form data";
}
else if(pass1!=pass2)
{_("status").innerHTML = "Password dont match";
}
else {
_("passbtn").style.display = "none";
_("status").innerHTML = 'please wait ...';
var ajax = ajaxObj("POST", "javat.php");
ajax.onreadystatechange = function() {
if(ajaxReturn(ajax) == true) {
if(ajax.responseText == "login_failed"){
_("status").innerHTML = "Fields empty.";
_("passbtn").style.display = "block";}
else if(ajax.responseText == "no match"){
_("status").innerHTML = "password mismatched";
_("passbtn").style.display = "block";
}
else if(ajax.responseText == "data wrong"){
_("status").innerHTML = "raw or pin wriong";
_("passbtn").style.display = "block";
}
else if(ajax.responseText == "username_mismatched"){
_("status").innerHTML = "username didnt match with username";
_("passbtn").style.display = "block";
}
else if(ajax.responseText == "success"){
_("status").innerHTML = "gotcha";
}
else {
_("status").innerHTML = "not now";
}
}
}
ajax.send("email="+email+"&pass="+pass+"&pass1="+pass1);
}
}
</script>
</head>
<body>
<form id="passchanger" onsubmit="return false;">
<input id="email" type="email" placeholder="Login Email for verification" />
<input id="pass" type="password" placeholder="Old password" />
<input id="pass1" type="password" placeholder="New password" />
<input id="pass2" type="password" placeholder="Confirm password" />
<button id="passbtn" onclick="paschange()">Log In</button>
<p id="status"></p>
</form>
</body>
</html>