vendredi 11 août 2017

Posting array of checkboxes in PHP

I have multiple checkboxes with names of adminMeta[], such as:

<input type="checkbox" name="adminMeta[name1]" value="1" />
<input type="checkbox" name="adminMeta[name2]" value="1" />

and so on and I also have text inputs like this too with the same names.

When the data is posted, I am looping through using a foreach loop:

foreach($_POST["adminMeta"] as $a => $b) {

}

inside the loop, I add/update the record in my database depending on whether it exists already or not.

But I am having some issues with checkboxes and knowing whether they are checked or not.

I have tried using if(isset($b)) but that hasn't worked.

How can I tell inside my loop, whether a checkbox is checked or not?




Aucun commentaire:

Enregistrer un commentaire