Hello All,
i am testing a function, below is the code for it. Here, i am searching a username by taking input of his email id by a user. when he enters the id, function sends it to php for result. it prints message for suceess or failure. Now here i want that the user name fetched from this page should be printed on another page called passme.php. how can i do it.
<?php
// AJAX CALLS THIS CODE TO EXECUTE
if(isset($_POST["e"])){
$e = mysqli_real_escape_string($db_conx, $_POST['e']);
$sql = "SELECT id, username FROM users WHERE email='$e'LIMIT 1";
$query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($query);
if($numrows > 0){
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$id = $row["id"];
$u = $row["username"];
}
} else {
echo "no_exist";
}
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Forgot Password</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="style/style.css">
<style type="text/css">
#passform{
margin-top:24px;
}
#passform > div {
margin-top: 12px;
}
#passform > input {
width: 250px;
padding: 3px;
background: #F3F9DD;
}
#passbtn {
font-size:15px;
padding: 10px;
}
</style>
<script src="js/main.js"></script>
<script src="js/ajax.js"></script>
<script>
function pass(){
var e = _("email").value;
if(e == ""){
_("status").innerHTML = "Type in your email address";
} else {
_("forgotpassbtn").style.display = "none";
_("status").innerHTML = 'please wait ...';
var ajax = ajaxObj("POST", "pass.php");
ajax.onreadystatechange = function() {
if(ajaxReturn(ajax) == true) {
var response = ajax.responseText;
if(response == "success"){
window.location="passme.php";
} else if (response == "no_exist"){
_("status").innerHTML = "Sorry that email address is not in our system";
} else {
_("status").innerHTML = "An unknown error occurred";
}
}
}
ajax.send("e="+e);
}
}
</script>
</head>
<body>
<div id="pageMiddle">
<form id="passform" onsubmit="return false;">
<div>Step 1: Enter Your Email Address</div>
<input id="email" type="text" onfocus="_('status').innerHTML='';" maxlength="88">
<br /><br />
<button id="passbtn" onclick="pass()">test function</button>
<p id="status"></p>
</form>
</div>
</body>
</html>