adrek Posted November 29, 2009 Share Posted November 29, 2009 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>'; } } Quote Link to comment Share on other sites More sharing options...
adrek Posted December 1, 2009 Author Share Posted December 1, 2009 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.