Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

A simple text hit counter [ ASP ]

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

yupfy45
Newbie


Posts: 7
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 0 (Donate)
Post: #1

Cool A simple text hit counter [ ASP ]


Our page is "mypage.html" and we are requesting information to complete it from "http://www.mycounter.com/hitcounter.asp" which may be located in the same or in a different site. The information provided by the second file will allow to get a text with the number of hits in our page.


mypage.html

Code:
<html>
<title>My page</title>
<body>

<script language="javascript" src="http://www.mycounter.com/hitcounter.asp"></script>

</body>
</html>



hitcounter.asp

Code:
<%
Wfile="c:\mydir\cgi-bin\hitcounter.txt"

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(Wfile)
hits = Clng(a.ReadLine)
hits = hits + 1
a.close

Set a = fs.CreateTextFile(Wfile,True)
a.WriteLine(hits)
a.Close
%>
document. write ("Number of hits since 2002/01/01: <% =hits %>")



* Lines 2. We will need a text file with a number as its unique content. The path to that file will be openned in variable "Wfile". Creating this page within cgi-bin directory is a good way to prevent visitor from accesing our counter (they will get an error when trying to access a ".txt
file within cgi-bin directory).
* Lines 4-8. We will open our file, read the content to a variable ("hits"), and in line 7 the variable will be increased by one.
* Lines 10-12 . We will create a new file with the same name (overwriting the previous file) with the content in "hits".
* Line 14. The response page will be a javascript code containing the number of hits.

23-09-2006 02:06 AM
Find all posts by this user Quote this message in a reply
robinson
Newbie


Posts: 18
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 0 (Donate)
Post: #2

RE: A simple text hit counter [ ASP ]


iam little surprised that you post this advanced script. You mentioned as you are only a biggner. Anyway, nice content grabbing.

23-09-2006 04:46 AM
Find all posts by this user Quote this message in a reply
fillbord
Newbie


Posts: 5
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 0 (Donate)
Post: #3

RE: A simple text hit counter [ ASP ]


Well, this is very optimised code. Nice job.

24-09-2006 06:19 AM
Find all posts by this user Quote this message in a reply
clookid
Advanced Member
***


Posts: 184
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 4
Points: 134 (Donate)
Post: #4

RE: A simple text hit counter [ ASP ]


It looks great but it is very suprising that you showed everybody the source code! Well done!


Veebra Articles - Computer and technology related articles.
07-10-2006 05:02 PM
Find all posts by this user Quote this message in a reply
walsh
Senior Member
****


Posts: 438
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 0
Points: 764 (Donate)
Post: #5

RE: A simple text hit counter [ ASP ]


Thanks for the simple text hit counter. This could be very handy for me.


25-07-2007 08:20 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  I would like to make a simple html page with a dynamic content using java script Cedik 10 431 11-09-2007 05:28 PM
Last Post: ivenms

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 21-11-2008, 03:56 PM


Copyright © 2002-2008 MyBB Group
Powered By MyBB