Hi,
I have inserted the code below into a site of mine to track where viewers came from (the referring page, if any) but on some pages I get the following warning:
Warning: Undefined index: HTTP_REFERER in d:\work\web sites\staffords5\mod-top on line 24
Here's the code:
<?
//traffic referrer - reports where last page visitor was at, if any
//get current date and time
$month = date("M");
$day = date("d");
$year = date("Y");
$time = ":".date("H").":".date("i").":".date("s");
//get information
$date = "[".$day."/".$month."/".$year.$time."]";
$referer = $_SERVER["HTTP_REFERER"];
//write to flat file if we have a defined referring page
$data = $date." - ".$referer."\n";
$filename = "./logs/".$year.$month.".log";
$fp=fopen($filename, "a");
fwrite($fp, $data);
fclose($fp);
?>
There must be a way of handling the undefined index without throwing a warning on my local system. I have searched for a bit but am not coming up with anything particularly useful yet.
My web provider must have warnings turned off as they don't show on the production server. However, I would prefer to resolve this warning on my local server.
Any advice appreciated,
Thanks,
-Steve