I have multiple checkboxes in a form and all have the same name. The form emails the results. My problem is that only the value of the last checkbox that is checked is sent.

Example:
<input type="checkbox" name="interests" value="1">
<input type="checkbox" name="interests" value="2">
<input type="checkbox" name="interests" value="3">

How can I get all of the checked values to appear?
After I complete this I have a similar form which has to insert the values in a single field in a database (preferably seperated by commas). Anyone have any suggestions?

    Change the name from interests to interests[]. That will make it collect all the values as an array.

      OK, now in my email it just says array, if I put interests[] in the results page i get an error. How can I get it to send me the contents of the array?

        Got it.

        I'll post what i did so maybe it could help someone else out in the future.

        for($i=0; $i < count($interest); $i++) 
        {
        $mailcontent .= "".$interest[$i]."\n";
        }

        Thanks for your help

          Write a Reply...