vendredi 3 mars 2017

Passing checkbox array from a Form to PHP variable

Thank you for looking at my question.

I am trying to do this: Use a form with checkboxes: user clicks on several checkboxes (for ONE question). Then hits "submit" Then a PHP page takes the form elements and puts them into variables. I can do this with other data, but not sure how to do it with checkboxes (since it is an array).

Could you help me?

$Q1 = $_POST['Hood'];  // This one is the array. Let's say it's an array that holds 3 words (red, white, blue). I'm fine if they all get stored in $Q1, I just don't know how to loop through the array (in $POST['Hood']) to get all 3 words in that one variable ($Q1)

$Q2 = $_POST['Handle'];
$Q3 = $_POST['Lever'];

So I think I need to figure out how to loop through $_POST['Hood'] in order to get each array element out of it. Please help :)

Thank you for your assistance!




Aucun commentaire:

Enregistrer un commentaire