Jump to content

Login Form - Ajax / PHP


havenpets

Recommended Posts

In Google chrome and Firefox my script works wonders. It looks amazing!

 

However, in internet explorer there seems to be a minor problem.

Once a login credential has been submitted (e.g. Username: hi, Password: hi) you cannot submit the form again with the same credentials. Seems like a security thing IE does so it's not viewing the same web page as before.

 

Code:

function check_credentials(){    
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "/xatron/login.php?username="+escape(document.getElementById('username').value)+"&password="+escape(document.getElementById('password').value), true);
        httpObject.send(null); 
        httpObject.onreadystatechange = function() { setOutput(); }
    }
}

function setOutput(){
    if(httpObject.readyState == 4){
// alert(httpObject.readyState); *** This is a test line...
        login_run(httpObject.responseText);
    }
}

function login_run(login_answer){
login_answer = login_answer;
if(login_answer == 0){
// alert false
}else{
document.location.href='/xatron/welcome.php';
}

 

And the form:

<table width="90%" cellspacing="0" cellpadding="0"> 
<tr> 
    <td width="50%">Username:</td> 
    <td width="50%"><input type="text" id="username"  /></td> 
</tr> 
<tr> 
    <td width="50%">Password:</td> 
    <td width="50%"><input type="password" id="password" /></td> 
</tr> 
</table> 

 

I am using jquery for the submit, but it's not the jquery giving the problems, it's the AJAX. any advice? Should "get" be "post" maybe?! Not sure.

Link to comment
https://forums.phpfreaks.com/topic/202337-login-form-ajax-php/
Share on other sites

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.