Daily hit counter

This counter will display the amount of hits that you get in a day , it creates a different text file with the day and month used in the file name . So the file created is along the lines of count1012.txt , which is the 10th day of the 12th month .

Code :

<%
On Error Resume Next
Dim objFSO , counter_file , count
'create instance of filesystem object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'if file exists open it
Set counter_file = objFSO.OpenTextFile(Server.MapPath("count" & Day(Now) & Month(Now) &".txt"))
'retrieve the count value
count = Clng(counter_file.ReadLine)
'increment count by 1
count = count + 1
'close the file
counter_file.Close
'create the text file
Set counter_file = objFSO.CreateTextFile( Server.MapPath("count" & Day(Now) & Month(Now) & ".txt"),true)
'write the value of count to the file
counter_file.WriteLine(count)
'close the file
counter-file.Close
'destroy object
Set objFSO = Nothing
%>
Todays count is <%= count%>

 

Sponsors

 

cover


Instant ASP Scripts


cover


Developing ASP Components (2nd Edition)


cover


Designing Active Server Pages