Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:36 PM   #1
Richard Summers
 
Richard Summers's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default counter reload

Hello,
I have a PHP Visitor Counter script that works perfect except that when the
user
clicks on the browser reload button the counter increases again.

Could someone please tell me what code i need to insert in order to prevent
this.

I am also a PHP newbie so please try to explain in idiot terms

Thank you.





 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 07-01-2007, 3:36 PM   #2
J.O. Aho
 
J.O. Aho's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default counter reload

Richard Summers wrote:
> Hello,
> I have a PHP Visitor Counter script that works perfect except that when the
> user
> clicks on the browser reload button the counter increases again.
>
> Could someone please tell me what code i need to insert in order to prevent
> this.
>
> I am also a PHP newbie so please try to explain in idiot terms


You could use a cookie, that is set and has an experiense time that is around
X hours, befor increasing, make a cheack if the cookie is there or not, if
not, then set the cookie, if there is a cookie, then do nothing.


//Aho

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:37 PM   #3
Ron
 
Ron's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default counter reload

"Richard Summers" <maria-kube@freenet.de> wrote in message
news:3f1066a4$0$30297$9b622d9e@news.freenet.de...
> Hello,
> I have a PHP Visitor Counter script that works perfect except that when

the
> user
> clicks on the browser reload button the counter increases again.
>
> Could someone please tell me what code i need to insert in order to

prevent
> this.
>
> I am also a PHP newbie so please try to explain in idiot terms
>
> Thank you.


Hi,

You can read details about the client's IP address in the array
$_SERVER

try $_SERVER['REMOTE_ADDR']

If you save that value you can check to see if the next click comes from the
same place and so ignore it.

The only trick is maintaining a persistent record of the address that will
survive from one page refresh to the next.

You could as Aho says use a cookie, or you could use a session variable. (
much the same really )
take a look in the manual, sessions are possibly a tad easier to set up for
a newbie.

Cheers

Ron


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:38 PM   #4
Shawn Wilson
 
Shawn Wilson's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default counter reload

Richard Summers wrote:

> I have a PHP Visitor Counter script that works perfect except that when the
> user
> clicks on the browser reload button the counter increases again.


There are a number of things you can do to prevent this, but all have
drawbacks. There is no perfect solution.

You could set a cookie or session variable. Execute your counter code if the
cookie or session is not set. If it is set, don't execute the code. This will
work until the cookie or session expires. It not work if cookies are disabled.

You could log their IP address and timestamp and only execute the counter code
if they haven't visited within 24 hours or whatever (probably too much hassle
for a simple counter). This would mean if a bunch of people behind a firewall
visited your site the counter would only increment by 1.

And a number of others, all pretty complex. This is a very common problem on
the Interweb. It comes up with counters, vote tabulators, statistics programs,
quizes, and a bunch of other scripts. Nobody has found the perfect solution.
Your best bet is probably to live with it or go with the cookie. If the
counter is critically important, use option 2 with a mySQL DB or flat file.

Shawn
--
Shawn Wilson
shawn@glassgiant.com
http://www.glassgiant.com


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Counter Strike MADMAX Help And Cheats 32 04-23-2008 11:53 PM
Help on php counter NEWBIE... Balbino Brito PHP 13 07-01-2007 3:59 PM
Free Counter? Tinkerbell Ebay Technical Questions 2 05-30-2007 1:37 AM
counter help . spot516 Gaming Questions 2 11-04-2006 3:47 PM
Counter Strike Cam The Games 1 08-29-2006 1:27 AM


Featured Websites




All times are GMT +1. The time now is 2:24 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98