Checkbox Form

I’m a PHP coding hobbyist. I’ve hit a brick wall on getting checkbox data from a form.
If I set up the form to manually check the box, the checkbox array is created perfectly.
If I code to automatically check some checkboxes, the checkbox array is empty when I submit.

This is my form line: <input type=“checkbox” name=“check_list[]” value="<?php echo $customer_id ?>" <?php echo $checked; ?>> This produces an empty array.
If I remove <?php echo $checked; ?> and manually check the checkbox it works.
$checked is either “checked” or “”.

Another observation. If I uncheck and check again an automatically checked checkbox, it works.

I created a form with two sets of your checkbox markup and some random values and it works for me.

You probably have a mistake in the overall html markup on the page or the values in those variables contain some html special characters that’s breaking the html.

It would require having all the relevant code and sample data that reproduces the problem to actually help and it wouldn’t hurt seeing what the ‘view source’ in your browser of the html for the entire page looks like.

This is what the view source looks like:
<input name="check_list[]" type="checkbox" value="697385" checked />

Sponsor our Newsletter | Privacy Policy | Terms of Service