Web Templates
Web Templates  
Photoshop Layouts  
Flash Templates  
Templates Resource - Web Templates
   
 
  Sign UpPassword
Templates Resource Services Support Specials Members View Cart
 
  Photoshop Tutorials
  HTML Tutorials
  ASP Tutorials
  CSS Tutorials
  Javascript Tutorials
  PHP Tutorials
  XML Tutorials
  Flash Tutorials
  Fireworks Tutorials
  3D Studio Max Tutorials
  Cinema 4d Tutorials
  Graphics
  Website Tools
  Web Templates
  About Templates Resource
  Affiliates Program
  TR Support
  Webmaster Resources
 Columbia Tech Support

WebDesignHelper.co.uk


 

Tutorials: ASP - Active Server Pages

Counter

Beginner

 

Learn how to make a hit counter in ASP.

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:

1. Call the FSO (File System Object) to open it for reading. If count.txt does not exist, the FSO will create it.

2. Use the On Error Resume Next function to disregard an error should ASP recieve one in the case that count.txt is empty.

3. Read the file to a variable.
4. Add one to the variable.
5. Close the file, then Open it for writing.
6. Write the file in Overwrite mode ("2").
7. Close the file.
8. Display the number of hits.
9. Clear all instances of FSO

Here it is in ASP:

<%
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Readfile = Server.MapPath ("count.txt")
Set File = FSO.OpenTextFile (Readfile, 1,true)
On Error Resume Next
Read = File.Readall
Count = Read
Count = Count + 1 'increments
File.Close
Writefile = Readfile
Set File = FSO.OpenTextFile (Writefile, 2)
File.Write("" & Count & "")
File.Close
Response.write("" & Count & "")
Set FSO = Nothing
%>

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.

 

This tutorial is provided to you by Spoono

More Tutorials
 

Active Server Pages Tutorials

AIM Screennames Viewer
This tutorial will show you how to make a script to see who has seen your AOL Instant Messenger profile.

Intermediate

Alternating Row Colors
Learn the basics of creating wonderfully abstract objects.

Intermediate

Browser Redirect
Learn how to do a Browser Redirect using the power of ASP.

Beginner

Cookies
Learn how to use cookies in ASP.

Intermediate

Counter
Learn how to make a hit counter in ASP.

Beginner

Database Connection
Learn the different ways to connect to different databases.

Intermediate

Database Insert
Learn how to insert a row into a MS Access database.

Beginner

Displaying Database
Learn a quick and easy way to display information from a database.

Beginner

Form Mail via CDONTS
Learn how to send mail using ASP and CDONTS

Intermediate

Form Mail via CDOSYS
Learn how to send mail using ASP and CDOSYS.

Intermediate

Number of Users Online
Use this code to display the number of users browsing.

Intermediate

Requests
Learn how to make use of requests.

Beginner

Sessions
Learn an alternative and effective solution to cookies in ASP using sessions.

Intermediate

String Functions
Learn the basic string functions available in ASP using VBScript

Beginner

XML Parsing
Use this nifty script to parse XML into HTML

Intermediate

Get help using .ASP here!

Get Free ASP Scripts here!

More Tutorials

Featured Web Templates

Web Template Preview 92312901

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313001

User Level:

Intermediate

Category:

Flash



Web Template Preview 92313101

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313201

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313301

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313401

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313501

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313601

User Level:

Intermediate

Category:

Flash


Web Template Preview 92313701

User Level:

Intermediate

Category:

Flash



Web Template Preview 92313801

User Level:

Intermediate

Category:

Flash

 

 

 

Templates Resource FAQ Services Terms of Use Site Map Support View Cart

© Copyright 2003-2008 Templates Resource