Adding an Access Counter
A text access counter
The Increment subroutine
The complete text access counter script
Seeding the Counter
Adding the Counter to Your HTML Page
With Server Side Includes
Without Server Side Includes
Creating the Template File
Modifying the access.pl Script
A graphical access counter
Incrementing the Counter
Creating the GIF Image
Returning the Graphical Counter Image
The Graphical Counter Script
Calling the Counter with the <IMG> Tag

[Previous] [Next]


Creating the Template File


The first thing to do is to change the HTML file, which you want to contain the counter, into a template file. Do this by changing the file's extension to .tmpl (.tmp if you want to use a three-character extension). Then edit the file, inserting the text that will surround the counter value. Use the value XXXX as a placeholder for where you will insert the access count. For example, using the HTML from the preceding example, you would place the HTML code in a file called text.tmpl, whose contents are shown here:
 <HTML>
 <HEAD>
 <TITLE>Example of Text Access Counter</TITLE>
 </HEAD>
 <BODY>
 <H1>Text Access Counter</H1>
 This is my Home page. Thank you for visiting. Please come again.
 <P>This page has been accessed XXXX times.
 </BODY>
 </HTML>



[Previous] [Next]