home>php>counter


Create a text counter viewable on a web page

1. Create an empty text file.
2. Name it count.txt
3. Upload this file into the same directory your web page is located.
4. Set permissions so count.txt can be written too (chmod 777).
5. Set up your Web Site so .html pages will accept PHP3 code.
6. Place the following code on the page:

<script language="php">
$file = fopen("count.txt","r+");
$count = fread($file, filesize("count.txt"));
fclose($file);
$count += 1;
$file = fopen("count.txt","w+");
fputs($file, $count);
fclose($file);
</script>
<script language="php"> include("count.txt"); </script>
<P>
6. Upload your web page and view.

7. See example file list.


Example appearance:

1249