Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: How to avoid mulitple submission of form in htmlby DanielSpaniel (Scribe) |
on Sep 10, 2011 at 01:05 UTC ( [id://925176]=note: print w/replies, xml ) | Need Help?? |
The JavaScript idea will likely work reasonably well, but probably won't stop page refreshes, etc from causing the same problem. Then, of course, there are those users with JS turned off as well, and browsers that won't handle it. In fact, I don't think you probably really care if somebody clicks on it a hundred times - you just don't want the click to count. The way I've done stuff like this in the past is to simply create a database table, which logs the IP address and date/time of the click, and then just read the table before you add to whatever counter you're incrementing for your "like button," to make sure that the same IP hasn't clicked the button more than once in a given period. It's not completely perfect, because you could have multiple users with the same external IP (i.e. from a corporate office, for example). There's not much getting around that, without combining the idea with cookies. However, using this method together with cookies and the JavaScript idea, I would think is a fairly solid plan. Of course, if your users have user-names then it would be easy enough to just flag them in a database table as having "liked" whatever ... but then I don't suppose you'd be asking the question in the first instance if they had user-names.
In Section
Seekers of Perl Wisdom
|
|