Total Hits using a Text File ASP Script - ASP Web Pro
  Active Server Pages Programming by ASP Web Pro

ASP Scripts

TOTAL HITS WITH TEXT FILE

On way to track the number of hits that your website receives is by using a text file counter.

The first thing to do is create a text file called totalhits.txt and save it within a directory called statistics.

Then, all you have to do is include the code below at the top of every page that you want hits counted from:

<%
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
HitsFile = Server.MapPath ("/statistics") & "\totalhits.txt"
Set InStream= FileObject.OpenTextFile (HitsFile, 1, false )
OldHits = Trim(InStream.ReadLine)
NewHits = OldHits + 1
Set OutStream= FileObject.CreateTextFile (HitsFile, True)
OutStream.WriteLine(NewHits)
%>

That's it. Now, you've got yourself a hit counter that uses a good old fashioned text file.

< Back to ASP Scripts


 

 

Main Menu
Home
ASP Scripts
ASP Tutorials
JavaScripts
Awards
Contact Us

Email This Page

Other Resources
ASP Web Hosting
Search Engine Submission
Programming Help

 

 

 

Other ASP Web Sites

Site Map

 

Last Updated:
21 March 2010