0
I’m trying to save this form in the database but when I got to the checkbox part I couldn’t save it in the bank. Follow the codes I tried to use.
HTML:
<div class="col-sm-12">
<label><b>Como você ficou sabendo do empreendimento? <span>*</span> </b></label>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Site" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Site</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Facebook" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Fecebook</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Google" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Google</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Jornal" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Jornal</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Panfletos" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Panfleto</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Imobiliaria" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Imobiliária</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="Outros" name="sabendo[]">
<label class="form-check-label" for="defaultCheck1">Outros</label>
</div>
PHP Saving in the bank:
if(isset($_POST['sabendo'])){
$listaCheckbox = $_POST['sabendo'];
foreach ($listaCheckbox as $sabendo) {
echo $sabendo;
$sql = "INSERT INTO form_cidades (nome, email, tempo, cordialidade, info, comentario, sabendo, imobi) VALUES('$nome', '$email', '$tempo', '$cordialidade', '$info', '$comentario', '$sabendo', '$imobi')";
$resultado = mysqli_query($conexao, $sql);
}
}
any errors? gets to mount the query correctly? any clues??
– Ricardo Pontual