1751980 Members
4800 Online
108784 Solutions
New Discussion юеВ

Counters

 
Kyle D. Harris
Regular Advisor

Counters

What is a few lines of Code to get a Hit Counter going ? Thanks

Kyle
9 REPLIES 9
Jerome Henry
Honored Contributor

Re: Counters

Hi Kyle,

Hit for what ? Web site ? In php ?

J
You can lean only on what resists you...
Kyle D. Harris
Regular Advisor

Re: Counters

Jerome,
Yes we have a program that throws data reports and puts them on a web page. I'd like to see how many people access this page. Currently the counter going now has this code:

WIDTH=60 HEIGHT=20 BORDER=0 HSPACE=4 VSPACE=2>

-------

I'd like to get it back to Zero, but I don't see how to set it back to Zero. Thanks

Kyle
Claudio Cilloni
Honored Contributor

Re: Counters

The sites the provide web counters give the way to erase them. Usually you need to login somewhere in their home page, insert username and password and they show up a menu to control your counters.
Try searching for instructions in you web-counter provider site.

hth
Claudio
Jerome Henry
Honored Contributor

Re: Counters

Well,

AS you are not controlling the variables used to increment the counter, digits.com does, then you have to ask them to reset it to 0, or do it from your control panel in their site. It's explained at :

http://www.digits.com/faq.html#Change


Use this access page, you should be able to do it from there :

http://www.digits.com/change.html

hth

J
You can lean only on what resists you...
Steven E. Protter
Exalted Contributor

Re: Counters

attaching a perl script for an invisible counter.

Easily inserted into a web pag.

This is for your referece though you could display the results as well.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Balaji N
Honored Contributor

Re: Counters

$filename="count.txt";
$FP = fopen ($filename,'r') or exit("unable to open counter file");
$count = (int) fread ($FP, filesize($filename));
fclose($FP);

$FP = fopen($filename,'w+') or exit("unable to open counter file");
echo "Count is $count";
++$count;
echo "Count is $count";
if(!fwrite($FP, $count)) {
exit("unable to write to counter file");
}

?>

a small php file.

to make this work, do this first.

echo 0 > count.txt

hth
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Caesar_3
Esteemed Contributor

Re: Counters

Hello!

The only problem with the code of Balaji
is that if you will have two requests in
the same time than you will have problem.
What you need to do is also add a ability
when you work on the file to do a lock that
the other will wait.

Caesar
John Meissner
Esteemed Contributor

Re: Counters

If you use apache it has built in web statistic tools.
All paths lead to destiny
Balaji N
Honored Contributor

Re: Counters

if you want a pretty graph from your http access log file, then go for webalizer.
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.