Guest kilbad Posted January 10, 2007 Share Posted January 10, 2007 I have an authentication script which, currently, once someone logs in, will give a message stating they have been logged in successfully. However, instead, I want to have it redirect the user to the page they came from. Therefore, I wanted to know how I can "grab" the last URL of the page the user came from? If I have that, I could then redirect them back.Thank you all so much in advance!Brendan Quote Link to comment Share on other sites More sharing options...
taith Posted January 10, 2007 Share Posted January 10, 2007 enjoy[code]<?function get_referrer(){ if(!$ref=@$HTTP_REFERER) $ref=$_SERVER['HTTP_REFERER']; return $ref;}echo get_referrer();?>[/code] Quote Link to comment Share on other sites More sharing options...
Guest kilbad Posted January 10, 2007 Share Posted January 10, 2007 Thanks for the quick response!I posted your script at [url=http://www.kilbad.com/DEVELOPMENT/test.php]http://www.kilbad.com/DEVELOPMENT/test.php[/url], but it is giving me some weird behavior.. not echoing the page when I come from somewhere else on kilbad.com..and ideas?Thanks again! Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted January 10, 2007 Share Posted January 10, 2007 works for me. the $_SERVER['HTTP_REFERER'] works via hyperlinks, so simply just going to a different address/hitting the back/forward buttom won't have the desired effect as far as i know.I tried the link you provided. I also skipped to http://www.kilbad.com/DEVELOPMENT/ and clicked on the test.php link, and all worked fine.I believe some browsers can be set up to mask the HTTP_REFERER though, so it'd be worth checking whether thats why it's not showing it for you. Quote Link to comment Share on other sites More sharing options...
taith Posted January 10, 2007 Share Posted January 10, 2007 works here also... and the HTTP_REFERRER is sent along with the headers, so any/all new browsers (anything after ie4) should support it... and it will only work for links, going directly there or refreshing without cache wont work. 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.