PDA

View Full Version : jQuery - Redirecting a Page



phantom007
08-01-2008, 02:58 PM
Hi

I am using PHP and jQuery to validate a login. If the user enters wrong user/pass, an error message will be shown on the index.php page, under a <DIV></DIV> tag. This works fine...

But, how do I make an index.php page redirect to welcome.php once the user enters the correct login information? Since everything is handled by jQuery, hence using the header("location: welcome.php") function will not work as the page is NOT refreshing.


Please help.


Thanx

abduraooft
08-01-2008, 03:06 PM
Since you are using ajax for login, I think replacing the login form and other related stuffs with a welcome message would be more elegant than a redirection. Though you could execute a simple javascript snippet like

window.location="welcome.php";

PS: Make sure that you are using a progressive enhancement (http://en.wikipedia.org/wiki/Progressive_Enhancement) methodology, otherwise your site would result serious accessibility issues.

phantom007
08-01-2008, 04:22 PM
How would jQuery know that the login is correct since the authentication process is handled by PHP?