You Are Here: Home »   Code Tuesday January 6th 2009

Code Library - php

Hit Counter - (1989 views)


create a file and name it count.dat
CHMOD count.dat to 666

<?

//set the count file
$counterfile "count.dat";

//check the file is readable
if(!($fp fopen($counterfile,"r"))) die ("cannot open counter file");

//grab the value and increase by 1
$count = (int) fread($fp20);
fclose($fp);
$count++;

//show the result, write the new value and close the file
echo "Site Hits: $count";
$fp fopen($counterfile"w");
fwrite($fp $count);
fclose($fp);

?>