ClassJr07 Posted July 25, 2013 Share Posted July 25, 2013 Hey Guys,I'd like to create a somewhat of a secure voting system where in a page we have about 5 to 10 pictures but in order to vote for one of the pictures you need to enter a "Voting code" once you type in your vote code you no longer can vote again.Is there something already out there for this? If not, could someone provide a bit of guidance how to compare their "vote code" with the one in a mysql database, and making it so that number cant be used again.thank you! Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 25, 2013 Share Posted July 25, 2013 How will they get the vote code and what would prevent them from getting another vote code? Normally you do this with an email address (verified) and possibly in combination with a cookie and/or their IP address. Even this doesn't doesn't guarantee that they can't vote with another email address. Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 25, 2013 Share Posted July 25, 2013 I'm sure there are plenty of things out there "similar" to this, but nothing that would meet your requirements exactly. Quote Link to comment Share on other sites More sharing options...
ClassJr07 Posted July 25, 2013 Author Share Posted July 25, 2013 Thanks for the quick reply's, so basically here is how this is going to work.. My organization runs a local pageant, the voting system is going to be used as "people choice" so people who attend the pageant can vote. the "voting codes" are going to be unique numbers printed on each ticket stub, so each ticket holder has a number which on the event date can be used to vote on "peoples choice" we are planning on having a few laptops or tablets lined up so people can vote during intermission times using their codes. Quote Link to comment Share on other sites More sharing options...
davidannis Posted July 26, 2013 Share Posted July 26, 2013 Put the codes into a database, once a code is used mark the record as used. I've done something similar where a user whose id was stored in $auth_id could vote only once, though in my example they could vote for up or down and change their vote. Here's the relevant bit of code from the up vote section. $id=$_POST['id']; $id = mysqli_real_escape_string($link, $id); $query="SELECT * FROM master_program_votes WHERE auth_id='".$_SESSION['auth_id']."' AND program_id='$id'"; if ($result= mysqli_query($link, $query)){ $master_program_votes= mysqli_fetch_assoc($result); //print_r($master_program_votes); if ($master_program_votes['auth_id']!=''){//user already voted once if ($master_program_votes['down_vote']==1) { //$vote_change=2; $update_query="UPDATE master_program SET up_votes=up_votes+1, down_votes=down_votes-1 WHERE program_id='$id'"; }else{ $no_vote_change=true;//they have already voted //$update_query="UPDATE master_program SET up_votes=up_votes+1 WHERE auth_id='".$_SESSION['auth_id']."' AND program_id='$id'"; } $master_program_votes['date']=date('Y-m-d'); $master_program_votes['up_vote']=1; $master_program_votes['down_vote']=0; $where = "WHERE auth_id='".$_SESSION['auth_id']."' AND program_id='$id'"; //print_r($master_program_votes); $update_result= dbRowUpdate('master_program_votes', $master_program_votes, $link, $where); }else{ $master_program_votes['date']=date('Y-m-d'); $master_program_votes['up_vote']=1; $master_program_votes['down_vote']=0; $master_program_votes['auth_id']=$_SESSION['auth_id']; $master_program_votes['program_id']=$id; dbRowInsertTEST('master_program_votes', $master_program_votes, $link); $update_query="UPDATE master_program SET up_votes=up_votes+1 WHERE program_id='$id'"; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.