Validating User Input
<p>I'm trying to figure out what would be the best way to deal with this on the back end.  When I submit my form I want to verify that there were selections made to both questions and the answers but still be able to tie in the right answers to the right questions.</p>

<pre><code>&lt;?php
&lt;fieldset&gt;

        &lt;legend&gt;Secret Questions&lt;/legend&gt;

        &lt;dl&gt;

            &lt;dt&gt;&lt;label for="question1"&gt;Question #1:&lt;/label&gt;&lt;/dt&gt;
        &lt;dd&gt;
            &lt;select size="1" name="questions[]" id="question1"&gt;
                &lt;option value=""&gt;- Select -&lt;/option&gt;
                &lt;?php
                while ( $row = mysqli_fetch_array ( $result, MYSQLI_ASSOC ) ) {
                    print "&lt;option value=\"".$row['id']."\"&gt;".$row['question']."&lt;/option&gt;\r";
                }
                ?&gt;
             &lt;/select&gt;
        &lt;/dd&gt;

    &lt;/dl&gt;

    &lt;dl&gt;

        &lt;dt&gt;&lt;label for="answer"&gt;Answer:&lt;/label&gt;&lt;/dt&gt;
        &lt;dd&gt;&lt;input type="text" name="answers[]" id="answer" size="54" /&gt;&lt;/dd&gt;

    &lt;/dl&gt;

    &lt;dl&gt;

        &lt;dt&gt;&lt;label for="question2"&gt;Question #2:&lt;/label&gt;&lt;/dt&gt;
        &lt;dd&gt;
            &lt;select size="1" name="questions[]" id="question2"&gt;
                &lt;option value=""&gt;- Select -&lt;/option&gt;
                &lt;?php
                mysqli_data_seek( $result, 0 );
                while ( $row = mysqli_fetch_array ( $result, MYSQLI_ASSOC ) ) {
                    print "&lt;option value=\"".$row['id']."\"&gt;".$row['question']."&lt;/option&gt;\r";
                }
                ?&gt;
             &lt;/select&gt;
        &lt;/dd&gt;

    &lt;/dl&gt;

    &lt;dl&gt;

        &lt;dt&gt;&lt;label for="answer"&gt;Answer:&lt;/label&gt;&lt;/dt&gt;
        &lt;dd&gt;&lt;input type="text" name="answers[]" id="answer" size="54" /&gt;&lt;/dd&gt;

    &lt;/dl&gt;

    &lt;dl class="submit"&gt;

        &lt;input type="submit" name="submit" id="submit" value="Enter" /&gt;

    &lt;/dl&gt;

&lt;/fieldset&gt;
?&gt;
</code></pre>
