Page 1 of 1

Simple Hit Counter

Posted: Thu Apr 26, 2007 5:46 pm
by gamez93
How to create your own customizable hit counter? It's just easy guys! With PHP, I'll show you how easy to make one using just a text file...

Code: Select all

Code:
<?php
$counter = fopen("counts.txt", "r");      //this here opens the text file
$count = fread($counter, 1024);          //reads the content of counts.txt
($counter);                                        //then closes the file
$count = $count + 1;                          //then it increments the number
echo $count;                                      //and displays the new number
$counter = fopen("counts.txt", "w");     //opens the text file again
fwrite($counter, $count);                     //and writes the new value
($dc);                                                //close the file
?>
And there is your own hit counter! just make sure that you have a counts.txt with any number you want the count to start... also chmod counts.txt to 777 so you won't have any issues with permission... if you want a more detailed information on your website hits, use a javascript...

Posted: Tue May 01, 2007 5:21 pm
by SHAdmin
Your 'How To' has been approved and you have been credited 15 points.