



(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 :
Date and Time Functions In ASP
FORMAT SPECIAL DATA
DISPLAY DATA FROM DATABASE
GLOBAL.ASA IN ASP
AIM Profile Screenname Viewer as a component of AIM Profile Designs
ASP.NET in Dreamweaver 8
String Functions
Creating Databases
Displaying Server Values In ASP
Reading form variables passed in the URL
ASP.NET Tutorial - Making image thumbnails
Passing Query Strings In Asp
The Recordset Object
Randomizer for ASP
Reading a Database
Counting Visitors In ASP
Processing Form Information In ASP
NEW WAY TO HANDLE VARIABLES
Text Editors and Software to Write ASP
ASP.NET 2 Special Purpose Folders













