PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hey guys I just have a quick question, I have a voting system that is supposed to limit votes with a cookie and make it difficult for users to spam, and it works except if you click really fast, it updates the database multiple times. Does anyone know how to prevent this effect, I also have the problem with some jquery forms if clicked really fast.
setcookie ("$id", "0", time()+(60*60*24*365));
//ok, now update the votes
if (!isset($_COOKIE["$id"])){
if($action=='vote_up') //voting up
{
//vote up
}
else f($action=='vote_down'){
//vote down
}
}
There is no solid way to do this with anonymous users. The best is to have them authenticate and store the fact that they have voted in the db.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
thanks a lot guys for the response. It is ok about using cookies because the user cannot even log in and start their session with cookies set to not accept and thus will not be able to vote in the first place without cookies set on accept so I will just try the sleep function out, since it does apply to other instances where cookies are not even used, but people can spam form inputs. I will let you know if it works when I implement.