Top

PHP Visitor Counter


PHP Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  3.5 (of 2 scores)
Date Added  May 18, 2005
Last Updated  Sep 04, 2008

Introduction

With this snippet all you have to do is the following:
- Create a file called "count.dat"
- Upload the file to your webserver
- CHMOD it to *777*
- Insert the PHP code below

Grab the Code

<?php
$counterfile = "count.dat";
if(!($fp = fopen($counterfile,"r"))) die ("cannot open counter file");
$count = (int) fread($fp, 20);
fclose($fp);
$count++;
echo "Hit counter: $count";
$fp = fopen($counterfile, "w");
fwrite($fp , $count);
fclose($fp);
?>

Comments

  (1)  RSS
Hawkee
Comments: 1,039
 
PHP Snippet:  PHP Visitor Counter
Posted on May 19, 2005 1:38 pm
This is a really simple solution to an old problem. Now with all the stat programs we have available it's not very necessary. Might be able to adapt something like this to track click throughs to a particular page or link.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom