01-17-2010, 03:01 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 10
Thanks: 4
|
Hit Counter Help
Hello
I have recently decided I was going to create a Hit Counter in PHP for my site when it goes up. Sadly when I run it it decided that it will not work for me.
The main file with all of the PHP coe in is called class.php. The contents of the file are:
PHP Code:
function showHitCounter($file) { $counterFile = $file; print '<div id="hit-counter">'; include($counterFile); print '</div>'; } function hit($file) { $T = 'T'; if (isset($_COOKIE['hit-today']) { print '<!-- This user has already had their hit counted today -->'; } else { $fo = fopen($file, 'r+'); $contents = fread($fo, 10)+1; fwrite($fo, $contents); fclose($fo); setcookie('hit-today', 'T', time()+86400); } }
Basicly, in the index file, I call the file class.php and then run the hit function.
I have a live example http://seaglass-jewellery.com/example/HitCounter/ (here)
Can anyone help me?
|
|
|
|