#******** BEGIN BODY ********
open
(GETCOUNT,"<count.log");
#open count log for input
$counter=<GETCOUNT>;
#assign contents of file to $counter
close
(GETCOUNT);
#close access to file
$counter++;
#increase $counter
by 1.
print "$counter
hits";
#print number of hits to users screen
open
(PUTCOUNT,">count.log");
#open count log for output
print PUTCOUNT
($counter);
#replace old counter value with new one
close
PUTCOUNT;
# close access to file
#******** END BODY *********
If we were to call such a program with a SUBMIT button, the current page would dissapear and be replaced by the output of this program. In order to display the hits on our page, we need a way to execute a program when a page loads, and embed the results back in that same page. This method is called a Server Side Include (SSI).
NOTE: Not all web servers support SSI. Some only work if the pagename ends with ".shtml" or ".html-ssi" and some have it completely disabled for security purposes. If you have difficulty with this exercise, check with your system administrator.
Here's how it works:
That's all so far, please send me your comments |