html counter

hey,
i am in need of a simple html counter for a private webpage. without any advertises and stuff

thanks for your help ;) (i got no mysql on the webserver!)
Comments
4
Does your webspace support php? If so, get a file-based counter... otherwise you will have to stick to random counter-services...
GOOOOOOOOOOGLE
html counter xD
Simple read-from-file counter.

<?php

/**
* @author Viperius
* @copyright 2010
*/

$counter_file = "counter.txt";
if( !($ref = fopen($counter_file, "r") ) )
die ("An error occured, cannot open file");
$counter = (int) fgets($ref);
fclose($ref);

$counter++; // updating counter

echo "You are visitor $counter";

// writing updated counter to counter.txt

$ref = fopen($counter_file, "w");
fwrite($ref, $counter);

// close not needed, but a good habit
fclose($ref);

?>

Remember to have "counter.txt" in the same dir. Also, webspace need php support.
Back to top