CodeAve.com CodeAve.com - ASP - Read/Write
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Daily Hit Counter
There are many ways to track usage of a website. The simplest way is with a hit counter, which will give you a raw count, but will not tell you how many people are visiting on any giving day. Utilizing the current date function a text document will be created utilizing the date as part of its naming convention in the same directory (providing that directory has user write access, you may need to place the documents in your cgi-bin depending on your provider) as the page we want the counter to appear on. The .txt file is first read to gain the value of the last hit count, one is added to that number, written to the .txt document, closed and the counter value is written as text to the page. If there is no text document (counter) for the current date one is automatically created. Refresh the content of the output page for a more complete illustration of the working counter.
View the Output
Text View
Print View
Mail this Link
Download the Code

<html>
<title>CodeAve.com(Daily Hit Counter)</title>
<body bgcolor="#FFFFFF">

<%
on error resume next

' Create a server object
set fso = createobject("scripting.filesystemobject")

' Target the text file to be read.
' The text file is continually updated with the current date from the server
set act = fso.opentextfile(server.mappath("daily_count-"& month(date()) & day(date()) & year(date())&".txt"))

' Read the value contained in the current day hit counter
' If there is no file for the current day the on error resume next command above
' will force the program to the next line 
counter = clng(act.readline) 

' Add one to the counter. If there was no value the counter will be set to a value of one
counter = counter + 1 

' Close the text object.
act.close

' Create a new text file on the server with the current date as part of the name
Set act = fso.createtextfile(server.mappath("daily_count-"& month(date()) & day(date()) & year(date())&".txt"), true)

' Write the counter value to the text object
act.writeline(counter) 

' Close the text object
act.Close 

'Write out the date and total hits for the current day
%>

<%= counter %> Total Hits for <%= date() %> 

</body>
</html>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3