954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Get Referrer

Hi,

I have a PHP Script. I need the referrer website address for this script.

I used the following 2 commands:
getenv('HTTP_REFERER');
$_SERVER["HTTP_REFERER"]

I believe both are the same.

But in majority of the cases I am unable to get any values using the above 2 variables.

I would not believe that 90% of the worlds browsers have javascript disabled.
Correct me if I am wrong.

Is there any 100% sure method of getting referrer ??

Thx
Vai

vaibhavs
Newbie Poster
6 posts since Feb 2008
Reputation Points: 11
Solved Threads: 0
 

Hi Vai,

Usually PHP will make the referrer automatically available in the variable, Have you had a look to see if these variables are available using phpinfo?

richie513
Junior Poster
158 posts since Feb 2008
Reputation Points: 19
Solved Threads: 11
 

These variables will be empty if someone
A.)gets to your site via a link with a target="_blank".
B.)types the url directly into the browser
C.)Came from a bookmark or favorite
D.)Right clicked to open your link in a new tab/window

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 
A.)gets to your site via a link with a target="_blank". D.)Right clicked to open your link in a new tab/window


I just tested it and it works.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

The code is working fine.
I get the value of referer, but for only a small % of hits.

Hence I was wondering if there are situations which are not captured by this PHP command.
OR if I need anyother command.

This is being done for evaluating hits from search engines.

Thx

vaibhavs
Newbie Poster
6 posts since Feb 2008
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You