Jump to content

[SOLVED] How to get URL of previous page..


Guest kilbad

Recommended Posts

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
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.