I am using PHP to create a voting system and I have a form that I am inserting into MySQL database. I am going to use JavaScript to ensure that the user selects at least one candidate but not more than three, but I want to validate on the server side as well. Here is the web form for the page:
<form method="post" action="post.php">
<input type="checkbox" name="vote[FR01]" value="ON"> Freshman Candidate 1 <br />
<input type="checkbox" name="vote[FR02]" value="ON"> Freshman Candidate 2 <br />
<input type="checkbox" name="vote[FR03]" value="ON"> Freshman Candidate 3 <br />
<input type="checkbox" name="vote[FR04]" value="ON"> Freshman Candidate 4 <br />
<input type="checkbox" name="vote[FR05]" value="ON"> Freshman Candidate 5 <br />
<input type="checkbox" name="vote[FR06]" value="ON"> Freshman Candidate 6 <br />
<input type="submit" name="submit" value="submit">
</form>
I know I will need to use a for loop however, could anyone explain how I could use those array key indexes which are the column names in the database?