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

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?

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.