



(64 ratings)
A hit counter is an essential part of a site to know how many people are coming to site. Here is an easy way to make a counter. All you need is access to ASP and be able to give a write access to a directory. We're going to save the amount of hits in a .txt file so that we won't need to worry about database connections.
Here is what we have to write in English:
- Call the FSO (File System Object) to open it for reading. If count.txt does not exist, the FSO will create it.
- Use the On Error Resume Next function to disregard an error should ASP recieve one in the case that count.txt is empty.
- Read the file to a variable.
- Add one to the variable.
- Close the file, then Open it for writing.
- Write the file in Overwrite mode ("2").
- Close the file.
- Display the number of hits.
- Clear all instances of FSO
<% |
Thats it! Just place the code into any file, and make sure the file as well as count.txt have read/write access on the IUSR_ account. If you are using a webhost, this access is probably already set.
20 Random Tutorials from the same category :
String Functions
The Connection Object
ASP Components
AIM Profile Screenname Viewer as a component of AIM Profile Designs
Iterating through Collections In ASP
Recordset Access Methods
NEW WAY TO HANDLE VARIABLES
Passing Query Strings In Asp
Date and Time Functions In ASP
Counter in ASP
Using Application Variables
GLOBAL.ASA IN ASP
SQL Access Methods In ASP
Randomizer for ASP
The Recordset Object
Installing ASP on your own computer
ASP.NET in Dreamweaver 8
DISPLAY DATA FROM DATABASE
Searching for Matching Values
Text Editors and Software to Write ASP














