mysql - PHP voting system - ensure a person can only vote once -


I am working on a voting system and I am sure someone can vote only once. I saw the IP handle but I read that there are some IPs in places such as universities, so if a person votes, then most universities are out of voting. Currently I use cookies, which is good till people do not know I am using cookies. Then it becomes easy to delete the cookie and vote again. Is there a reliable way to store a user's vote and to ensure that they can not vote again? This is my current voting script:

  & lt ;? Php included ("config.php"); // Checks the URL for any GET variable and removes them. $ Url = $ _POST ['url']; $ Arr = Explosion ("?", $ Url, 2); $ Url = $ arr [0]; // ensures that no person went to /vote.php if (empty ($ _ POST ['url'])) {Print '& lt; Script & gt; Window.location = "errorpage"; & Lt; / Script & gt; '; } Else {// Unique ID number for specific match up is $ Idnumber = $ _POST ['id']; // Check to see if there is a cookie with unique mailup ID name. If (! $ _COOKIE [$ idnumber])) {// If voted, go back and display the already voted error Print '& lt; Script & gt; Window.location = "'. $ Url.'? Error = Voted ';  gt;';} Else {// If the user does not have a cookie, then set it to end in 1 year in. the Setkyuki ( "$ idnumber", "1", Strtotem ( '1 year')); // a_vote or sets variable b_vote $ VoteRow = $ _POST [ 'concealment']]; // column name for array allow $ allowable values ​​= array ( "a_vote", "b_vote"); // if not $ Votro a_vote or b_vote, go to the error page. if (! In_array ($ voteRow, allowing $)) {Print '& lt; script & gt; window.location = "errorpage"; & lt; / script & gt; ';} Else {// current vote joins and adds a new value. Foreign currency ($ db- & quot; query ( "SELECT go from $ $ voteRow votes Milan = $ idnumber ' "$ row as) {$ votes = $ row [$ voteRow];} $ Newvotes = $ votes + 1; // update query to send new votes amount to $ Sql ​​=" UPDATE` vote `sET $ voteRow =: newvotes WHERE 'matchup` =: id"; $ statement = $ db- & gt; prepare ($ sql); $ Stetment- & gt; bind value ( "Nuvots" $ Nuvots); $ Statement- & gt; Bind value (": id", $ idnumber); $ Count = $ statement- & gt; carry about (); $ Db = null; // Vote on the success page. Print '& lt; Script type = "text / javascript" & gt; window.location = " '. $ Url.'? vote = success '; & lt; / script & gt;';}}}? & Gt;  

< / Html>

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -