Last URL (source) ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Last URL (source) ?

Post by gite_ashish »

Hi,

How to find the last URL.

Like, i have one Anchor tag in many pages ( <A hRef=next.php> click </A> ). But the link that opens up (next.php) is same everywhere.

In the next.php how can i find, from which page i have been open.


:!: The simplest way i got is to add one query string variable in every Anchor tag to identify the last page. But, is there any other smart way ?!?!
Is any HTTP header that can give these details ?


Thanks & Regards,
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You could use $_SERVER['HTTP_REFERER'] but:
php manual wrote:'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
Probably best to pass a variable in the URL.

Mac
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Thanks !

Post by gite_ashish »

Hi,

Yes, got what i was looking for.

I checked this variable in IE4/win, IE5/win, IE6/win, nn4.04/win, nn4.08/win, nn4.75/win and lynx-2.8.3-2/rhl6.2 .... it is working.

But $_SERVER[HTTP_USER_AGENT] is NOT reported in phpinfo().

Thanks with best regards,
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Yes it can work in almost any browser but the user can modify it or turn it off - it is not reliable and if you need to know which page someone has come from it is not the best method.

Mac
Post Reply