Click to See Complete Forum and Search --> : Hit counter


chesswill
05-19-2006, 02:14 PM
Please suggest the best way to count my site traffic?

Wisest Guy
05-19-2006, 02:19 PM
To a page? A folder? Your whole site? Any combination of these?
What server are you using?

chesswill
05-20-2006, 05:46 PM
www.gordonengraving.co.uk

Raremandan
05-20-2006, 07:44 PM
You mean like how many people have visited your site? It would be very easy to do with PHP.

You will need to create a blank text-file and CHMOD it to 777. The reason I am using a text-file as a mySQL based one would take me a bit longer to write and test.


<?

$myfile = "visits.txt";

if(file_exists($myfile))//if the file exists
{
$var = fopen( $myfile,'r+');
$visits = fread($var,filesize($myfile));
rewind( $var );
$visits++; //increments the actual number of vists by 1
fwrite($var, $visits);
fclose($var);
}
else
{
print "File $myfile doesn't exist...";
Die();
}
$message = sprintf("",$visits);
print $message;
?>

If you know PHP it will all be familiar and I won't explain, if you need any more help feel free to PM me.