Jump to content

Variable Error?


Lol5916

Recommended Posts

Here's the error:

Notice: Undefined index: HTTP_REFERER in /home/*******/public_html/******/referer2.php on line 5

 

Script is:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$line = ('------------------------------------------'); 
$ref = $_SERVER['HTTP_REFERER']; 
$ip = $_SERVER['REMOTE_ADDR'];
$d = date('l dS \of F Y h:i:s A');
$mes = '<br>Referer: '.$ref."<br>";
$mes = 'IP: '.$ip."<br>";
$mes = "Date & Time: ".$d."<br>";
$mes = ".$line.";  
$file = "logger.html";
$fh = fopen($file, "a");
fwrite ($fh, "$mes\n"); fclose($fh);

?>

 

What's the problem?

Link to comment
https://forums.phpfreaks.com/topic/123328-variable-error/
Share on other sites

This is not an error but a notice only, and there are ways to turn them off if you want.  Depends on how tidy you want your code to be, of course.

 

Before you refer to the value in the array, you need to check if it is set.  Not all user agents set the value for $_SERVER['HTTP_REFERER'].

Link to comment
https://forums.phpfreaks.com/topic/123328-variable-error/#findComment-636953
Share on other sites

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.