View Full Version : Simple PHP Counter


XxJenny
04-01-2004, 07:28 PM
This doesn't count unique hits :( But it is simple!

Open 2 new notepad files and in one put in this -

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

save as counter.php

Now open up the other and save it with nothing in it (or you can put a number in this is the file which the hits are stored in) and save as counterlog.txt

Upload them both in the same directory and CHMOD counterlog.txt to 766

Include or iFrame the counter.php using something like this

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

Or use paths but use the correct directories etc

Eric
04-05-2004, 10:17 PM
will it work if you cant chmod?

Cherchezlafemme
04-05-2004, 11:12 PM
No, some PHP programs need special properities to work :)