<input type="checkbox" id="one" name="form[age[]]" value="1"/><label for="one">0 to 12 months</label>
How do I reference the name in PHP once it has been submitted using POST. I am trying to collect all the checkbox values and then implode age[], but I need to put this in a form[] for form validation.
When i print_r[$_POST['form']['age'], it displays Notice: Undefined index: age
You should use
name="form[age][]"for every checkbox with age value, and then after you send those values to PHP they will be available as an array $_POST[‘form’][‘age’].Example:
will result an array in PHP like: