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]


Calling the Counter with the <IMG> Tag


With the graphical counter script completed, you are ready to add the graphical access counter to your Web page. As with the text access counter, you need to create and seed the count.dat file. If you didn't follow the text access counter example, read the section "Seeding the Counter" earlier in this article. The graphical access counter is called from the <IMG> HTML tag. The line
 <IMG SRC="/cgi-bin/graphical-counter">


calls the graphical-counter file and displays the results returned from the script. Listing 9 contains the HTML code for an example using the graphical counter script, and Figure 4 shows how the page would appear in the Netscape browser.
Listing 9: HTML Example Using the Graphical Counter
<HTML>
 <HEAD>
 <TITLE>Example of the Graphical Access Counter</TITLE>
 </HEAD>
 <BODY>
 <H1>Graphical Access Counter</H1>
 This is my Home page. Thank you for visiting. Please come again.
 <P>This page has been accessed <IMG SRC="/cgi-bin/graphical-counter">
 times.
 </BODY>
 </HTML>






Figure 4: The graphical access counter


[Previous]