Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hit counter can work better

Status
Not open for further replies.

michelleqw

Programmer
Joined
Jan 4, 2004
Messages
120
Location
DE
Dear PHP users,

We are making a hit counter on our second page with the help of a MySQL table.
Calling this page we are using the "get method": SecondPage.php?uc=u.
It works fine but the only problem is that everytime we are pressing F5 the hit counter is increasing because the "?uc=u " is still on the address. How can we start this page with the "get" information and after the page is built on the explorer address we see: SecondPage.php?

Nice regards

Michelle.
 
You could generate a serial number for each page and only count it once
 
include_once(counter.php);

and do your count from there ? only 1 visit will be counted, not any F5's.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
nm I lied, what you expect to get and what you actually get are not quite the same.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
I should have said random number, serial implies a well a series !. It should be easy to do when you generate the page in PHP
 
Michelle,

I would look at visitor IPs and log those along with a timestamp.

Everytime a visitor calls your page, simply look up his/her IP in the DB then examine the timestamp and consider if the hit counter should be increased or left alone.

I realise that users could have new IPs on revisits, but per default a dynamic IP assigned to a client are (on our intranet this is true) typically the same (the client asks the DHCP to keep it's previous IP). Mind you this is not always true §:O) but a rough and easy way to make a hit counter.

Does this make sense to you?

Good Luck §:O)


Jakob
 
dkdude
IP seems like a very "rough" method to count. I'm thinking of all the AOL proxy servers for example that issue the same IP for may clients behind the proxy. Or even, the proxy might change for the same client ...
 
You could (using GET) pick up the ?uc= value. If it was not empty then record the count in the database and then redirect (server-side) to the same page - but without the ?uc= in the URL.

If the user pressed F5, then it would refresh the page - but would not trigger the counter increase (because the URL wouldn't contain the ?uc=).

Just a suggestion.

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top