



(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 :
Passing Query Strings In Asp
ASP.NET Tutorial - Making image thumbnails
Searching for Matching Values
Processing Form Information In ASP
Recordset Access Methods
The Connection Object
Using Application Variables
FORMAT SPECIAL DATA
GLOBAL.ASA IN ASP
The Recordset Object
Server-side Scripting
AIM Profile Screenname Viewer as a component of AIM Profile Designs
Counter in ASP
ASP Components
String Functions
NEW WAY TO HANDLE VARIABLES
Installing ASP on your own computer
Randomizer for ASP
Iterating through Collections In ASP
Server Variables In ASP














