Skip to content Skip to sidebar Skip to footer

Error When Submitting Checkbox To MySQL

I have the following php code for submitting the form to the database the only problem is with the checkboxes ... on submitting the form this shows up Warning: join() [function.joi

Solution 1:

Your checkboxes should be in the form of an array...

<input type="checkbox" name="ckb[]" value="strenthofmaterials";>
<label for="StrengthofMaterials"> Strength Of Materials </label>
<input type="checkbox" name="ckb[]" value="dynamics";>
<label for="StrengthofMaterials"> dynamics </label>

Note : It is ckb[] instead of just ckb


Solution 2:

$ckb = array();
foreach($_POST['checkbox'] as $val){
    $ckb[] = (int) $val;
}
$ckb = implode(',', $ckb);

Try this one. $ckb should be an array. For security purpose $val is converted in integer.


Post a Comment for "Error When Submitting Checkbox To MySQL"