[TUT] Super Simple Page Hits Counter
Hey!
This is just to show some newbies to coding how to make a Hits Counter.
1. Create a File called hits.dat
2. Copy this code and read the comments to understand it!
PHP Code:
<?
//See's if you made hits.dat!
if(file_exists("hits.dat"))
{
//This part shows that you did!
$exist_file = fopen("hits.dat", "r");
$new_count = fgets($exist_file, 255);
//Adds a New Hit
$new_count++;
//closes the file
fclose($exist_file);
//shows the new hit count
print("$new_count");
$exist_count = fopen("hits.dat", "w");
fputs($exist_count, $new_count);
fclose($exist_count);
}
else
{
//You Didnt Make a Hits.dat File!
echo("Please make a File named Hits.dat!");
?>
It Doesnt Detect by IP or anything. JUst shows how many times the Page has been viewed.
Pretty Bad Ey!