Forum Moderators: coopster

Message Too Old, No Replies

Http_referer

         

jackvull

10:15 am on Sep 21, 2005 (gmt 0)

10+ Year Member



Hi
I have a site that logs each visitor's IP address and the referring site they came from for statistics.
I am gettig the following error every time someone logs in:
(Notice) Undefined index: HTTP_REFERER

Any reason why this would happen? Could it because there is no referrer? The code I use to get this is:

$query = "insert into statistics
(page, time, referrer, browser, ip, timeStamp) values
('$_SERVER[REQUEST_URI]', now(), '$_SERVER[HTTP_REFERER]', '$_SERVER[HTTP_USER_AGENT]', '$_SERVER[REMOTE_ADDR]', now() )";

$result = mysql_query($query);

RonPK

12:02 pm on Sep 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Could it because there is no referrer?

Yep. Some browsers are set not to pass the referrer, and some firewalls block it as well. HTTP_REFERER is notoriously unreliable.

Try using something like
empty($_SERVER['HTTP_REFERER'])? '' : $_SERVER['HTTP_REFERER']
in your code to get rid of the notice.