Here is a script I made a while back to do counting. Just do the following things:
1. create a file "counter.txt" and type your starting value in it (ex. 0)
2. give the file "counter.txt" read/write permission
3. save the below code to a file (ex. counter.php)
4. include the file where it is needed in your pages (ex. <?php include('counter.php'); ?>
5. Thank me by creating a link to my page or by using Provision Tech when you need a web designer or web host.
PHP Code:
<?php
/////////////////////////////////////////////
////This is a very simple counter
////created by Classic Web Development
////http://www.classicwebdevelopment.com/
////////////////////////////////////////////
if(@$file = fopen("counter.txt","r")){
$counter = fgets($file);
fclose($file);
$counter++;
$file = fopen("counter.txt","w");
fwrite($file, $counter);
fclose($file);
echo 'Number of Downloads: '.$counter."<br><small>created by <a href=\"http://www.provisiontech.net/\">Provision Tech</a>" ;
}else{
echo 'File counter.txt could not be opened or it does not exist.';
$file = fopen("counter.txt","w");
fwrite($file, "0");
}
?>
Website Hosting & Design | Classic Web Development
Last edited by Provision : 04-07-2006 at 01:51 AM.
|