home info scripts guides links contact

Basic hit counter

There are plenty of counters out there to use, lots of them remotely hosted and copy-paste codes. These counters tend to be unreliable, ad-forced, and hard to customize. So you can make your own simple text counter using PHP!

Counterlog.txt

Open up a new document in notepad and save it as counterlog.txt. don't type anything in there, just save it.

Now open up another document in notepad and paste in the following code:

<? php
$viewss = file('counterlog.txt');
$views = $viewss[0]; $views++;
$fp = fopen("counterlog.txt", "w");
fwrite($fp, $views);
fclose($fp);
print $views;
?>


Save this as Counter.php

that's it for making the counter. now wasn't that fun? Upload all files to root directory and chMOD counterlog.txt to 766 in your FTP program.

Displaying the counter

To display the counter, paste the code below anywhere you want it:

<?php
include ('counter.php');
?>


After that tag you can put and word/words after it like "hits" or "times visited"


copyright 2008 Maggie N