-
Hit Counter?
I need a hit counter for my website, but I dont want to use one of these free ones that you have to include an advert with.
Could anybody supple me with the code that I can use to get a hit counter to appear on my page, or link me to a website that offers such a service.
-
Here an basic PHP one which I normally use:
PHP Code:
<?php
$document = ("hits.txt");
$hits = file($document);
$hits[0] ++;
$fp = fopen($document , "w+");
fputs($fp , "$hits[0]");
fclose($fp);
echo("The Message you want showed: $hits[0]");
?>
Create an .txt file called hits.txt and change the permissions to 777 ;).
-
Its simple to make a php counter;
make a file called counter.txt, write the number "1" in it and save it.
Then make a file called counter.php and add this code to it;
PHP Code:
<?php
$filename = "counter.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize($filename));
fclose ($fd);
$contents=$contents+1;
echo $contents;
$fp = fopen ($filename, "w")
fwrite ($fp,$contents);
fclose ($fp);
?>
Now use a php include to include counter.php to your website :)
-