0

Hello everyone! I am a student and I am currently working for online voting system for my school. I am having a hard time how to prevent users/students from multiple votes. Could please give me some example that users can only vote once using their ID number? I have a login system. I know there is a lot of tutorial out there but mostly they used IP address. Any help would be greatly appreciated. This is my code so far:

-----CUT-----

    <form action="candidates.php" method="post">
    <?php
    include('voting_connect.php');
    {
    $result = mysql_query("SELECT * FROM candidates WHERE c_position='President'")
    or die(mysql_error());  

    echo "<center><table id='tables' class='sortable'>";
    echo "<tr><th scope='col' abbr='' class='nobg'>&nbsp;&nbsp;</th> <th>President:</th></tr>";

    while($row = mysql_fetch_array($result))
      {
    echo "<tr>";
    echo "<td scope='row' class='spec'>" . '<input name="selector[]" type="radio" value="'.$row['c_ID'].'">' . "</td>";
    echo "<td>";
    echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
    echo "</td>";
    echo"</tr>"; 
     }
     echo"</table></center>";
    }
    ?> 
    <br></br>
    <?php
    include('voting_connect.php');
    {
    $result = mysql_query("SELECT * FROM candidates WHERE c_position='Vice President'")
    or die(mysql_error());  

    echo "<center><table id='tables' class='sortable'>";
    echo "<tr><th scope='col' abbr='' class='nobg'>&nbsp;&nbsp;</th> <th>Vice President:</th></tr>";

    while($row = mysql_fetch_array($result))
      {
    echo "<tr>";
    echo "<td scope='row' class='spec'>" . '<input name="selector1[]" type="radio" value="'.$row['c_ID'].'">' . "</td>";
    echo "<td>";
    echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
    echo "</td>";
    echo"</tr>"; 
     }
     echo"</table></center>";
    }
    ?> 
    <br></br>
    <?php
    include('voting_connect.php');
    {
    $result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'")
    or die(mysql_error());  

    echo "<center><table id='tables' class='sortable'>";
    echo "<tr><th scope='col' abbr='' class='nobg'>&nbsp;&nbsp;</th> <th>Secretary:</th></tr>";

    while($row = mysql_fetch_array($result))
      {
    echo "<tr>";
    echo "<td scope='row' class='spec'>" . '<input name="selector2[]" type="radio" value="'.$row['c_ID'].'">' . "</td>";
    echo "<td>";
    echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
    echo "</td>";
    echo"</tr>"; 
     }
     echo"</table></center>";
    }
    ?> 
    <br />
    <br />
    <input type="submit" value="Vote!" name=submit"/>

-----CUT-----

2
Contributors
1
Reply
5
Views
5 Years
Discussion Span
Last Post by titosd
0

You can use student id for this problem

before submit his vote check if this student id exist in the voting table, if no add it else give him a msg

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.