Jump to content

$_SERVER['HTTP_REFERER'] not working!!!


robcrozier

Recommended Posts

Hi, im trying to record a referring URL into a database to act as part of a web statistics facility on a web project that i'm doing however strangely the '$_SERVER['HTTP_REFERER']' function will only record referring URLs from my website and not from others. For example if i have been to www.google.com and then navigate strait to the web page on my website which records the referring address, nothing gets recorded and the database record is left blank. All other data is successfully written to the database however and it is not a problem with variables etc as like i have already said, it will record web URLs from my website.

 

Can anyone shed any light on the matter for me???

 

Cheers!

Link to comment
https://forums.phpfreaks.com/topic/41256-_serverhttp_referer-not-working/
Share on other sites

Sure, heres what im doing in a file called stats_logg which is called at the top of my home page only:

 


$referal = $_SERVER['HTTP_REFERER']; 

$query = "INSERT INTO stats(address, date)VALUES ('$referal', now())";
mysql_query($query)or die("Error, query failed");

The referrer only works if you click a link. Unless you have about $1,000,000,000,000, you don't have a link on the google homepage. Did you search for yourself and click a link or did you go to google and then type your own address into the address bar or click a bookmark?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.