Hey. I have a form where I have four checkboxes relating to the same type of choice. That is, I want them to be able to select more than one too, hence checkbox not radio.

So, I made four <input type='checkbox' name='mycheckbox'> with different value='value' attributes. My php code retrieves the data from the form as follows (POST form):

$mycheckbox = $_POST['mycheckbox'];

However, when I echo this variable out I notice that only the last of the four checkbox's value is recorded. Is there any way to get all the ones that are checked?

Or do I have to make each checkbox a different name...

    <input type='checkbox' name='mycheckbox[]'>

    note [] in name attribute

    now $_POST['mycheckbox'] will be a array of the checked vales

      Am I supposed to put some kind of number in the brackets? Or will it just index it for me...and does it index from 0

        Write a Reply...