//This is a simple hit counter. When user link to this page or reload this page , counter will increase 1
if (!isset($_SESSION["counter"]))//check variable "counter" exist or not
{
$count_file="count_data.txt" ; //file name that will be stored the hit_times
$count_file_open = fopen("$count_file", "r+");
$hit_times = fgets( $count_file_open, 10 );
$hit_times=$hit_times+1;
rewind($count_file_open);
fwrite( $count_file_open, $hit_times );
fclose($count_file_open);
$counter=true;
session_register("counter");
}
else
{
$count_file="count_data.txt" ; //file name that will be stored the hit_times
$count_file_open = fopen("$count_file", "r+");
$hit_times = fgets( $count_file_open, 10 );
fclose($count_file_open);
}
echo $hit_times;
?>
|