A
Anonymous
Guest
I have a registration form i am trying to work on as part of a project and in my code i want to know which checkboxes have been selected and which havent. SO far the below code will enter in to a varchar DB the entry "on" if the checkbox is checked but nothing else, so i am not sure how to make sense of that, i.e. would it not be off, off, on, on if you only were to select the last 2 checkboxes for example. here is some of my code only the relevant bit for checking each box, adding to SQL and the html checkbox itself..
Code:
<?PHP
$Industrybtn = '';
if(!empty($_POST["Industry"]))
{
foreach($_POST["Industry"] as $Industry)
{
$Industrybtn .= $Industry . ', ';
}
}
$stmt = mysqli_prepare($con, "INSERT INTO inf VALUES (?, ?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, "ssssss", $int, $inf_fname, $inf_lname, $inf_email, $inf_password, $Industrybtn);
mysqli_stmt_execute($stmt);
?>
<div class="checkboxes">
<input type="checkbox" name="Industry[]" id="checkbox_id" style="margin-bottom:15px"><label for="checkbox_id">Dinning</label>
<input type="checkbox" name="Industry[]" id="checkbox_id1" style="margin-bottom:15px"><label for="checkbox_id1">Jewellery</label>
<input type="checkbox" name="Industry[]" id="checkbox_id2" style="margin-bottom:15px"><label for="checkbox_id2">Clothing</label>
</div><br>