Log use IP address : _SERVER « Form « PHP

Log use IP address


$address = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$browser = $_SERVER['HTTP_USER_AGENT'];

$file = fopen("log.html",  "a");  

$time = date("H:i dS F");
fwrite( $file, "<b>Time:</b> $time<br>" );

if( $address != null)
  fwrite( $file, "<b>IP Address:</b> $address <br>");

if( $referer != null)
  fwrite( $file, "<b>Referer:</b> $referer<br>");  

fwrite( $file, "<b>Browser:</b> $browser<br/><hr>");  



Related examples in the same category

1.$_SERVER extracts valuable server- and script-related information
2.Adjusting behavior based on an environment variable
3.Deciding what to do based on request method
4.Getting Times and Dates of Files: $_SERVER['SCRIPT_FILENAME']
5.PHP $_SERVER Arguments
6.superglobal variables
7.Output file time
8.Some Common $_SERVER Elements