Pioneer Skin
Login  ::  Register
Thursday, February 09, 2012
 
- - - - - - - - Sponsorship Advertisement Area - - - - Thank you to our Sponsors - - - - - - - - -
New Horizons Computer Learning Centers

We are please to introduce the new and improved discussion forum. It should eliminate the issues we've been having with the discusson board in the past. The old forum will still be available in "read only" mode HERE in case anyone wants to review the old topics that were posted.

WGD Forum: Discussion
Subject: Simple Hit counter
Prev Next
You are not authorized to post a reply.

Author Messages
Kristin123User is Offline

Posts:0


10/16/2008 4:13 AM  

A hit counter will let us know how many times a page is accessed. In case one visitors loads the page several times, the hit counter will increase several times (but this is likely to happen only a few times).

The code for the hit counter bellow will save the number of hits in a file named
counter.txt (the name of this file may be changed). Each time the page is loaded, the file will be read, the number will be increased by one and the new number will be saved to the same file.

 


//The file where number of hits will be saved; name may be changed; p.e. "/counter_files/counter1.txt"
$counterfile = "
counter.txt";

// Opening the file; number of hit is stored in variable $hits
$fp = fopen($counterfile,"r");
$hits = fgets($fp,100);
fclose($fp);

//increading number of hits
$hits++;

//saving number of hits
$fp = fopen($counterfile,"w");
fputs($fp,
$hits);
fclose($fp);

//printing  hits; you may remove next line (and keep the counter only for your records)
print
$hits;

?>

To use this code, copy it to your page in the exact position where you want to show number of hits.

 

http://www.infysolutions.com

outsourcing software development

tgoodsonUser is Offline
Newbie
Newbie
Posts:32


11/05/2008 2:17 AM  

Probably ought to specify that that is PHP code (there are other scripting languages, you know.)  I've been using something simular for quite a while now, works great.

** Tom **

You are not authorized to post a reply.
Forums > Web Design > Programming > Simple Hit counter



ActiveForums 3.7
Home | Membership | Events | Forum | MyPage | Login
Copyright 2007-2008 by WGD Forum :: Designed by ZapWebDesign.com