Requires a file called counter1.dat in the same folder as the script
CHMOD the counter file to 755
<?php
//simple counter example v1.0
//open the counter file in read only mode
$counterfile = "counter1.dat";
if(!($fp = fopen($counterfile,"r"))) die ("cannot open counter file");
//read the value stored in the file
$thecount = (int) fread($fp, 20);
//close the file
fclose($fp);
//increment the count
$thecount++;
//display the count
echo "visitor no : $thecount";
//open the file again in write mode and store
// the new count
$fp = fopen($counterfile, "w");
fwrite($fp , $thecount);
//close the file
fclose($fp);
?>
CHMOD the counter file to 755
<?php
//simple counter example v1.0
//open the counter file in read only mode
$counterfile = "counter1.dat";
if(!($fp = fopen($counterfile,"r"))) die ("cannot open counter file");
//read the value stored in the file
$thecount = (int) fread($fp, 20);
//close the file
fclose($fp);
//increment the count
$thecount++;
//display the count
echo "visitor no : $thecount";
//open the file again in write mode and store
// the new count
$fp = fopen($counterfile, "w");
fwrite($fp , $thecount);
//close the file
fclose($fp);
?>
0 comments:
Post a Comment