Please i am searching for a fake download counter for my blog or a fake hit counter. that i can use multiple times on diffrent pages.
Here is what i am asking for, example immeditely after posting it
Post title Justin Bieber
Post Body blah, blah
Download: 3
REFRESH
Post title Justin Bieber
Post Body blah, blah
Download: 7
REFRESH
Post title Justin Bieber
Post Body blah, blah
Download: 12
Thats what i am looking for, please can someone share the code for me
<?php
$filename = 'path/to/counter.txt';
$fp = fopen($filename, "w+");
$i = fread($fp, filesize($filename));
$i = $i+5;
fwrite($fp, $i);
fclose($fp);
echo "Downloads: ".number_format($i);
?>
There you go.. try to be a little bit more HQ with your posts though.
I would suggest using a cookie. Like this:
if(isset($_COOKIE['counter'])) {
$value = $_COOKIE['counter'] + 4;
setcookie("counter", $value, time()+3600);
} else {
$value = "3";
setcookie("counter", $value, time()+3600);
}
echo $_COOKIE['counter'];
Hope this works for you. Here's an online example, just uploaded for you: http://inspirad.com/test.php