SpeedCrazy Posted July 13, 2011 Posted July 13, 2011 hey guys, I am trying to implement into my script the ability to redirect the user to the login page when he attempts to view a logged in user only page and then from their to the page he attempted to view. I have it working as far as the login page but after that it fails. login redirect: $rURL = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if($isUserLoggedIn == false){ header("Location: ".$path."myLoginPage.php?redir=".$rURL); exit; }//end if The first bit grabs the url for the page that the user attempted to view. That works fine. The next bit also works fine. It breaks when we get to the login script here: if(isset($_REQUEST["redir"]) && $_REQUEST["redir"] != ""){ $url = $_REQUEST["redir"]; } else ($url = "secure/index.php"); ... if(!$errors){ ... header('Location: '.$url); exit; } I can echo $url and it will show the one i want but as soon as it executes i am stuck at the index.php, and yes im sure that wasn't the page i was trying to access. Any ideas? Thanks, Speed Share this post Link to post Share on other sites More sharing options...
flareback Posted July 13, 2011 Posted July 13, 2011 silly question here but are you passing the redir variable to your login script? It looks like you're passing the redir variable from the page trying to be accessed to the login page, but then make sure you pass it to the login script as well. That's the only tip I've got for you, it looks like it should work. Share this post Link to post Share on other sites More sharing options...
SpeedCrazy Posted July 13, 2011 Posted July 13, 2011 Yeah i realized that about 2 mins ago. It now works. One of those things that in hindsight its like how could i have been so dumb. Thanks Share this post Link to post Share on other sites More sharing options...
flareback Posted July 13, 2011 Posted July 13, 2011 we've all been there. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now