Hi folks,
I'm creating an HTML form that has multiple checkbox inputs for online quizzes for students. The checkboxes all have the same name ("6"), and different values (for example, "Hg", "Mn", "Y", "Se"). Students are to choose all of the correct answers. However, whenever I execute the following code, only the final value is echoed out--not all selected values, which is what I want.
Here's the HTML code for the form:
<p><font size="2" face="Arial, Helvetica, sans-serif"><strong>6.)
Which elements do you think should be measured (choose all that
apply)?</strong></font></p>
<blockquote> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="checkbox" name="6" value="Y">
Yttrium (Y)<br>
<input type="checkbox" name="6" value="Ca">
Calcium (Ca)<br>
<input type="checkbox" name="6" value="K">
Potassium (K)<br>
<input type="checkbox" name="6" value="Pb">
Lead (Pb)<br>
<input type="checkbox" name="6" value="Na">
Sodium (Na)<br>
<input type="checkbox" name="6" value="Pt">
Platinum (Pt)<br>
<input type="checkbox" name="6" value="Hg">
Mercury (Hg)<br>
<input type="checkbox" name="6" value="Mn">
Manganese (Mn)<br>
</font> </blockquote>
And here is the PHP code:
$answer6 = $_POST['6'];
echo $answer6;
I've gotten some information that I should treat the output as an array, and I tried this, but I still keep getting only the last selected value returned, and not the whole set of selected values. I hope that my problem is clear. Could somebody please point me in the right direction?