Make Urtutorials.com your homepage | Add to Favorites      


Visitor Info  

Visitor log
This tutorial will show your how to create a visitor log that logs all your visitor details

Code:

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 
?>

You can either include into the page or just put the code on the page. Also you need to CHOMD 777 visitor.txt
 
Discuss this tutorial in the Forum.

Other good stuff:-


Submited by:- Farooq Azam

Discussions Forum Login:-

Username:
Password:  

Remember Me    
Not a member?
Register here

Copyright © UrTutorials.com - All rights ® reserved A Publispain Group Website