Hi,
I have a HTML Page and i want to get the Hit count of this page once opened and to be displayed in that HTML page using a text file which will store the value of count.
Thanks in advance....
Ravi
Hi,
I have a HTML Page and i want to get the Hit count of this page once opened and to be displayed in that HTML page using a text file which will store the value of count.
Thanks in advance....
Ravi
<?php
$data2 = file_get_contents("data2.txt") + "1";
$fp = fopen("data2.txt", "w");
fwrite($fp, $data2);
fclose($fp);
?>
or use this:
<?php
$text_file = "hits.txt";
function hitCount($file) {
$fp = fopen($file,rw);
$count = fgets($fp,9999);
fclose($fp);
$fp = fopen($file,w);
$count += 1;
print "$count ";
fputs($fp, $count);
fclose($fp);
}
/* display it on your page */
echo 'Page hits:' . hitCount($text_file);
?>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.