stuart.cole Posted December 10, 2007 Share Posted December 10, 2007 Hi, I have a nice little log in script for members of my site, and I can redirect on successful login to a specific page, but I am struggling to know what to do to get them back to the page they logged in from. To be more specific - the site uses multiple session variables to generage certain pages, just using if($retval){ header("Location: ".$session->referrer); ends with the right page, but without the session variables so therefore a problem. If I let this page load and then backpage it works fine as it is going to the previously loaded page with the variables intact. Simply put - is there a way to automate the process of forcing a backpage once another page has loaded? Thanks Stu Quote Link to comment Share on other sites More sharing options...
JacobYaYa Posted December 10, 2007 Share Posted December 10, 2007 $_SERVER['HTTP_REFERER'] (not 100% reliable) Quote Link to comment Share on other sites More sharing options...
stuart.cole Posted December 10, 2007 Author Share Posted December 10, 2007 Hmm, as the login calls process.php to log in / out / update etc this just seems to call up a blank page as process.php is calling itself but with no actions ... if that makes sense $_SERVER['HTTP_REFERER'] (not 100% reliable) Quote Link to comment Share on other sites More sharing options...
JacobYaYa Posted December 10, 2007 Share Posted December 10, 2007 Do you do all your login on one page or you have a login form which (ie login.php) that submits to the processing page (process.php)? Dependant on how you are doing things another way is to have a hidden input like this echo '<input type="hidden" name="redirect" value="'.$SERVER['PHP_SELF'].'" />'; You can then do something like if(isset($_POST['redirect'])){ header('Location: '.$redirect); }else{ //Send them to a login success page or index.php } Quote Link to comment Share on other sites More sharing options...
stuart.cole Posted December 10, 2007 Author Share Posted December 10, 2007 My pages are made up from multiple php files (have a look at http://www.moneysavingdeals.co.uk ) and the pages are made from the header, points file, login file, left, centre, right and footer. On the login part, the call is to process.php to action the logging in/out/changes etc and as each action happens it changes it's headers to redirect on completion of the action which works very well. To save members going through the process of finding the site they want cashback from again it would be ideal to reload the originating page - which works, mostly. The issue is it doesn't have the session information as it's been through process.php so calls for merchant ID and Category ID fail and it returns a blank page. I could write the session info calls into process.php into it but it would be a pain as this file has shown itelf to be quite fragile in the last - getting it to finish process.php and change it's header to 'back page' would be an easy answer as once logged in you would return to the previous page still logged in and able to do what was wanted from there, but I don't know if it's possible. Does this make sense? So the question I suppose is - can you do a header redirect to go back 1 page or not? Quote Link to comment Share on other sites More sharing options...
stuart.cole Posted December 10, 2007 Author Share Posted December 10, 2007 My apologies, the first answer actually held the key. Thankyou for your help JacobYaYa 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.