The Wayback Machine - https://web.archive.org/all/20050206214241/http://www.freescripts.com:80/text-counter.php

Cheap Web Hosting
Unix Web Hosting
Windows Web Hosting
Reseller Web Hosting
Ecommerce Web Hosting
Web Hosting Service
 
Free Scripts
 
Banner Ads
Chat
Form Processor
GuestBook
MailFile
PostCard
 
Free Snippets
 
Cookies
Header/Footer
Random Text
Text Counter
 
Scripts Directory
 
ASP
ASP.NET
Java
Javascript
Perl
PHP
Python
XML
 
Misc.
 
Web Hosting
Website Promotion
Mall
Traffic-UK.com
Barcelona Property
Web Hosting
Hosting Directory
ASP & PHP Tutorials
Buy UK Traffic
PHP Classes
Meta Language
Blog Rankings
Web Hosting
Cheap Web Hosting
Web Design
Windows XP
Cheap Web Hosting
Add Listing
Contact Us
 
  Jumpline Hosting
With the ability to host 6 domains on one account, you can?t beat this low price. More Information.
 
Netfirms Web Hosting
Trusted by over 1,000,000 people and growing
 
Interland
Sell and Market Your Products Online
 
Dot5 Hosting
Award Winning Web Hosting JUST $5p/m





Description

This script will include a simple text counter on the page of your choice. The scripts do not require a database of any kind.

Text Counter in PHP

Just include the following code where you want to include a file in a .php file.
<?
$counter_file = ("counter.txt");   //file where count is stored
$visits = file($counter_file);    //puts the count in a variable
$visits[0]++;               //add 1 to the counter

$fp = fopen($counter_file , "w");           //open the file for write
fputs($fp , "$visits[0]");           //write the new value to the file

fclose($fp);            //close the file

print $visits[0] . " visitors so far.";
?>

Text Counter in ASP

Use the following code to include a counter in your page in ASP. Create the file counter.txt with nothing but the number 0 in it before you try to use the following script

<%
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("C:\path\to\counter.txt")

oldNumber = CLng(oFile.ReadLine)   'read the current count out of the file

oFile.Close    'close the file because we're done reading it

oldNum = oldNum + 1     'add 1 to the current counter number

Set oFile = oFSO.OpenTextFile("C:\path\to\counter.txt",2,true)

oFile.WriteLine(oldNum)           'write the new counter value to file
oFile.Close                    'close the file

Response.Write(oldNum & " visitors so far.")
%>

Copyright © 1996 - 2003 JumpBug Enterprises
Read our Privacy Statement
Read our License Agreement