Simple Hit Counter

Write your "How To" regarding anything you are comfortable with and you feel it will help the forum members.

NOTE :: All threads started here will appear only after the approval from Administrator
Post Reply
gamez93
Posts: 58
Joined: Wed Feb 21, 2007 2:14 pm

Simple Hit Counter

Post 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...


SHAdmin
Posts: 2089
Joined: Sat Dec 18, 2004 11:28 am
Contact:

Post by SHAdmin »

Your 'How To' has been approved and you have been credited 15 points.
Post Reply