dimanche 18 octobre 2015

Checked checkbox not sending value with $_POST foreach

I have a PHP mailer form with this in the code:

foreach ($_POST as $key => $value) {
    $querydetails = $querydetails  . '<li>' .  $key . ': ' . $value . ' </li>';
}

Simple right? Works as normal for text inputs but not checkboxes.

I have this for the checkboxes in the form:

<input type="checkbox" name="fsfnew" value="I'd like x!">
<input type="checkbox" name="fsfused" value="I need y!">

If I check just one checkbox, both keys get sent through, but no value.

If I check no checkboxes, I get both keys sent through without values.

If I check all checkboxes, I get both keys sent through without values.

This should be simple, and I have been at it for hours and can't work it out.




Aucun commentaire:

Enregistrer un commentaire