mardi 25 août 2015

Issue getting $_POST from multiple checkboxes

I made a form with multiple checkboxes in it, as follows:

<form action="" method="post" enctype="multipart/form-data">
<?php
    foreach($room_numbers as $room_number){
        echo '<input type="checkbox" name="rooms[]" value="'.$room_number.'">';
    }
?>
</form>

where every $room_number is different.

After the submission of the form, if no one of the checkbox is checked I get an empty array, while if one is checked, I get the POST as follows:

Array(
    [rooms] => 
)

Why is $_POST['rooms'] always empty?




Aucun commentaire:

Enregistrer un commentaire