Jump to content

[SOLVED] This AJAX login script is not working... Very Simple Too!


Dethman

Recommended Posts

Hey guys this following AJAX that I made is not doing anything can someone look thru it and tell me where exactly I went wrong?

 

Entire Login Page:


<script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(){
var ajaxRequest;  // The variable that makes Ajax possible!

try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
} catch (e){
	// Internet Explorer Browsers
	try{
		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try{
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e){
			// Something went wrong
			alert("Your browser broke!");
			return false;
		}
	}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 4){
		var ajaxDisplay = document.getElementById('ajaxDiv');
		var num = ajaxRequest.responseText;

		if(num = 1){
		setTimeout("location.href='redirection.php'", 0);
		}
	    else{
			document.all.main.innerText = "Some random text.";
		}
	}
}
var age = document.getElementById('user').value;
var wpm = document.getElementById('pass').value;

var queryString = "?age=" + age + "&wpm=" + wpm;
ajaxRequest.open("GET", "1/ajax-example.php" + queryString, true);
ajaxRequest.send(null); 
}

//-->
</script>



<tr>
<td colspan="3" align="left"><a href="javascript:TINY.box.hide()"><font color="#000;">close login screen</font></a></td>
</tr>
<div id="wrap">
<div id="top">

</div>

<div id="mid">
	<div id="content-wrap" align="center"> 

<form name='myForm'>
<table width="200" class="login" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><b><font color="red">Login</b></td>
<td> </td>
<td><div id='main'></div></td>
</tr>
<tr>
<td><font color="black">Username</td>
<td><input type="text" name="user" size="16"></td>

</tr>

<tr class="row2">
<td><font color="black">Password</td>
<td><input type="password" name="pass" size="16"></td>
</tr>
<tr>
<td><a href="javascript:ajaxFunction()">LOGIN!</a></td>

</table>
</form>


<div id="bot">
</div>
© NimbusGames, LLC. 2009-2015

</div>

 

Ajax-Example.php Page:

 

<?php

$user=$_GET['age'];
$pass=$_GET['wpm'];
if(isset($user){
$gooduser="Tmal";
$goodpass="enterprise";

if($gooduser=$user && $goodpass=$pass){

echo("1");

}
else{
echo"2";
}	
}



?>

 

Any Help with this would be amazing

<?php

$user = $_GET['age'];
$pass = $_GET['wpm'];
if(isset($user)) { // missed a parenthesis )
$gooduser = "Tmal";
$goodpass = "enterprise";

if($gooduser == $user && $goodpass == $pass){ // = assigns a value | == checks if two values are equal

   echo 1;
   
}
else{
   echo 2;
}   
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.