Hi all,
I am trying to make a script for maximal hit counter using below codes. So if user hit for bigger than 2, it would re assign the file of hitcounter.txt into "0" (as if in resetting) .. I tried this code but it does not work
<?php
//database SQL
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
//echo $hits[0];
if ($hits[0] =='1')
{
echo "1";
}
if ($hits[0] =='2')
{
echo "2";
}
if($hits[0] !='1'|$hits[0] !='2')
{
$hits[0] = '0';
}
Thank you for the tips