9 Years
Discussion Span
Last Post by Shanti C

Here is a neat and helpful PHP script that can count unique page views on your website. First you need to open up a new page in your text editor and paste in this code.

$filename = "hits.txt";

$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo $hits;

$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename));
$fd = fopen ($filename , "w");
$fcounted = $fstring."\n".getenv("REMOTE_ADDR");

then save the page as counter.php

Next open up another new page in your text editor and just save it as hits.txt
Then upload all of the files onto your server and CHMOD hits.txt to 0777 or just 777.
After that open up your main page or the page you will be placing the counter on and pste in the following code.

include ('counter.php');

then save and close that page. If needed, re-upload the file(s) to your server. Very simple and easy to use.

check this for reference:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.