Jump to content

Ajax login not updating


adrek

Recommended Posts

Hi,

 

I have an ajax login form that, when submitted, will take the users credentials, send them to my ajax script which will use my php script to authenticate it. My problem is that once the authentication has passed the page will stay the same. I was able to isolate it to this function. If the login is correct it should update the page to say "you are logged in" but you have to submit the form again for it to do anything. I got it to work by adding an alert in there but ideally it should just update the page with out this alert. Does anyone have any suggestions.

 

Thanks

 

 

function login(){
xmlhttpPost("auth.php");
document.getElementById('password').value = "";
alert("");  //Will not work with out this.
if(document.getElementById('status').innerHTML == "1"){
	alert('asdf');
	document.getElementById('content').innerHTML='<font color=\"white\">you are logged in</font>';
}
}

Link to comment
Share on other sites

i should prolly show more code.

 

this is the auth.php page

 

<?php
require_once "includes/core.php";
require_once "includes/user.class.php";

$user = new User($_POST['email'], $_POST['password']);
$auth = $user->getAuth();
if($auth)$string = "<font color=\"green\" face=\"Verdana\" size=\"2\">Access Approved</font>";
else $string = "<font color=\"red\" face=\"Verdana\" size=\"2\">Access Denied</font>";

setcookie("auth", $auth);
print $string."<div style=\"display:none\" id=\"status\">$auth</div>";
?>

 

i was trying to play around with setting the values of cookies and divs to see if i could read one of those with the javascript login function but for some reason the js function will not read the cookie or div until the second time it is run through. any ideas?

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.