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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.