1
I am developing a registration form but I had to include a field (Radio Button) in my project. However, I am unable to save the Radio Button Insert to my Mysql database.
The code below is in bootstrap pattern, but the variable name which was used to define the fields that would be saved named database, is already being used by the flexRadioDefault format. This way, I cannot use it to perform the insert in the bank, as was done in the other fields of the form.
Example:
<!-- FORMULÁRIO -->
<div class="col-sm">
<label for="cep">Cep</label>
<input type="text" class="form-control" placeholder="CEP" name="cep">
</div>
<div class="form-group col-sm-3">
<label for="cargo">Cargo</label>
<input type="text" class="form-control" placeholder="Digite seu Cargo" name="cargo">
</div>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault">
<label for="flexRadioDefault1">Homem</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault">
<label for="flexCheckDefault2">Mulher</label>
</div>
</div>
// INSERT BANCO
include "conexao.php";
$nome = $_POST['nome'];
$telefone = $_POST['telefone'];
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$endereco = $_POST['endereco'];
$bairro = $_POST['bairro'];
$estado = $_POST['estado'];
$cep = $_POST['cep'];
$cargo = $_POST['cargo'];
$sexo = $_POST['sexo'];
$sql = "INSERT INTO `formulario`(`nome`, `telefone`, `email1`, `email2`, `endereco`, `bairro`, `estado`, `cep`, `cargo`, `sexo`,) VALUES
('$nome','$telefone','$email1','$email2','$endereco','$bairro','$estado','$cep','$cargo','$sexo')";
Oi Caio. Add the snippet of PHP code where you try to save the contents of this form in your database.
– André Walker
I tried to put code under it the same way, but it didn’t work..
– Caio Filipe