*

Recent

Author Topic: Simple Hit Counter  (Read 9119 times)

Trasion

  • Guest
Simple Hit Counter
« on: July 21, 2009, 03:08:33 PM »
This will add a hit counter to your website.

Go into your FTP, and make a new file in the directory "templates/YOURTEMPLATENAME"

Make the file called 'counter.php'

Add this code to it:

Code: [Select]
<?php
$count_my_page 
= ("hitcounter.txt");
$hits file($count_my_page);
$hits[0] ++;
$fp fopen($count_my_page "w");
fputs($fp "$hits[0]");
fclose($fp);
echo 
$hits[0];
?>

In the same directory, make a new file called 'hitcounter.txt'

Now in that same directory, open up 'header.php'.

Search (CTRL+F) for:
Code: [Select]
Users Online: <? echo countusersonline(); ?>
Replace it with:
Code: [Select]
Total Hits: <?php include ("counter.php"); ?><br />
Users Online: <? echo countusersonline(); ?>

You now have a working hit counter!

To reset it at any time, open 'hitcounter.txt' and set the number to zero.