How do I see $HTTP_REFERER

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
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

How do I see $HTTP_REFERER

Post by fatman »

I have 2 URL's resolving to the same page. I want to know which one?

I need the value of $site

If I use this code:

Code: Select all

if (preg_match ("/www.mydomain.com/i", "$HTTP_REFERER")) { 
    $site = "hprp"; 
}
It does not recognise the URL when I land on the page, but if I refresh, it does.

Any ideas on how I see the URL the first time I land?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

For starters: Not all browsers send a http_referer header (this becomes pretty obvious with IE7) so i would not recommend to rely on that.

How would you define 'resolve' to the same page. In essence a HTTP request contains a header with GET (or POST) $url $httpversion. Via $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] you can rebuild the $url...
Post Reply