|
Before starting you will need to create a new
html file. Leave the file blank and save it as
visitor.txt. Let's get to the code, it's quite simple.
<?php
// file
which the script writes to
$counter = "visitor.txt";
// Date
$today = getdate();
$month = $today[month];
$mday = $today[mday];
$year = $today[year];
$current_date = $mday . $month . $year;
// writes to file visitor.txt;
$fp = fopen($counter, "a");
$line = $REMOTE_ADDR . "|" . $mday . $month .
$year . "\n";
$size = strlen($line);
fputs($fp, $line, $size);
fclose($fp);
//this shows up on the
page
echo "IP Address: " . $_SERVER['REMOTE_ADDR'] . "<br>";
// Display IP address
echo "Referrer: " . $_SERVER['HTTP_REFERER'] . "<br>";
// Display the referrer
echo "Browser: " . $_SERVER['HTTP_USER_AGENT'] . "";
// Display browser type
?>
|