Graxeon Posted August 14, 2009 Share Posted August 14, 2009 I'm not a real PHP guru but I can't grasp the idea of how to have a poll and make a cookie that will disable users from voting for a certain amount of time. Here's a voting script that I found very useful: http://www.w3schools.com/php/php_ajax_poll.asp But just by refreshing the page I can vote again. I tried googling "how to save a cookie" and this is what I came up with: http://blazonry.com/javascript/cookies_save.php But I don't know how to combine those 2 scripts. Any help? Edit: Oh I also did search on these forums and found a few posts with the same problem...but they were from people that didn't speak newbie xD Link to comment https://forums.phpfreaks.com/topic/170290-vote-once/ Share on other sites More sharing options...
play_ Posted August 16, 2009 Share Posted August 16, 2009 Are you sure you wanna go with cookies? Someone can just delete the cookie and vote again, and again, and again... you're better off doing it by IP address Link to comment https://forums.phpfreaks.com/topic/170290-vote-once/#findComment-899418 Share on other sites More sharing options...
Graxeon Posted August 16, 2009 Author Share Posted August 16, 2009 Well...for ip logging I found this but I still need help combing the 2: <?php $ip = $_SERVER['REMOTE_ADDR']; $pagina = $_SERVER['REQUEST_URI']; $datum = date("d-m-y / H:i:s"); $invoegen = $datum . " - " . $ip . " - " . $pagina . "<br />"; $fopen = fopen("ips.html", "a"); fwrite($fopen, $invoegen); fclose($fopen); ?> Link to comment https://forums.phpfreaks.com/topic/170290-vote-once/#findComment-899554 Share on other sites More sharing options...
Graxeon Posted August 17, 2009 Author Share Posted August 17, 2009 Oh shoot posted in the wrong forum. No wonder the replies are a little slow in here Someone move this to PHP Coding Help, please. This has nothing to do with Zoomla or any other PHP app, sorry my mistake xD Link to comment https://forums.phpfreaks.com/topic/170290-vote-once/#findComment-899757 Share on other sites More sharing options...
play_ Posted August 17, 2009 Share Posted August 17, 2009 Moved. In short: when user votes, check the database if that user has voted. if he hasnt Store the IP and time of vote in the database. if he has get the time of his last vote and the current time to do your time-span calculation if X time has passed He can vote. register his vote and update database so time of his last vote is the current time If you want to implement cookies, you can fit that in there as well. but like i said, very easy to bypass Link to comment https://forums.phpfreaks.com/topic/170290-vote-once/#findComment-900077 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.