For some reason when I try to insert data from a form’s checkbox fields into a MySQL database, all that shows up in the database field is the word ‘Array’.
Below is the HTML form code I’m using:
<div class="optionalField">
<fieldset>
<legend>Colors:</legend>
<label for="availability_checkbox_0" class="labelCheckbox">
<input type="checkbox" name="colors[]" id="colors[]" class="inputCheckbox" value="Rose madder" />
Rose madder</label>
<label for="availability_checkbox_1" class="labelCheckbox">
<input type="checkbox" name="colors[]" id="colors[]" class="inputCheckbox" value="Cerulean blue" />
Cerulean blue</label>
<label for="availability_checkbox_2" class="labelCheckbox">
<input type="checkbox" name="colors[]" id="colors[]" class="inputCheckbox" value="Sap green" />
Sap green</label>
<label for="availability_checkbox_3" class="labelCheckbox">
<input type="checkbox" name="colors[]" id="colors[]" class="inputCheckbox" value="Pompeii Red" />
Pompeii Red</label>
<label for="availability_checkbox_4" class="labelCheckbox">
<input type="checkbox" name="colors[]" id="colors[]" class="inputCheckbox" value="Pyrrol Crimson" />
Pyrrol Crimson</label>
</fieldset>
</div>
And here is the PHP code that retrieves the array values (or is supposed to):
$colors = implode(',', $_POST['colors']);
// SQL injection and Headers are dealt with later...