Kelowna web design and hosting

Kelowna web design and web hosting company 1-250-870-3393

Web site updated: 07/26/2007
About us
Web design portfolio

Mission statement
Testimonials
Careers
Contact us
Sitemap

Our services
Kelowna web design

Search engine marketing
Database design
Kelowna web hosting
Support

Free web design tutorials
HTML tutorials
Javascript tutorials
ASP tutorials
Website marketing
Search engine marketing
Flash tutorials

Free web design articles
Web design
Internet business
Computer programming
Advertising & internet marketing
Search engine marketing
Small business startup
Web hosting
Computer hardware

Web designer resources
Kelowna web mail
DNS lookup tool
E-Books
Tutorial XML feeds
Article XML feeds
Search engine marketing Tools


Web Design Tutorials ASP web site design tutorial Counter in asp

Counter in asp


Counter in asp 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.

Rate This Material: Bad 1 2 3 4 5 Excellent
 




Kelowna web design and web hosting
© 2010 www.kagemedia.com
Kelowna web design and development | Kelowna web hosting
Kelowna website marketing | Kelowna database design | Links

Serving:
Kelowna BC - Penticton BC - Vernon BC - Westbank BC - Winfield BC

FREE web design and hosting package.
Win a FREE web design!
We are giving away a completely free web design and web hosting package every month.

Click here for details