![]() |
|
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. |
| |||||||
| 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. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| 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. | |||
|
| Advertisements |
| | #2 | ||
| 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 | |||
|
| | #3 | ||
| "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 | |||
|
| | #4 | ||
| 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 | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: counter, reload |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
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 | ||||
|