I use 3 radio buttons to select the input voltage of an equipment (110V, 220V or Automatic). If I put only 2 radio buttons, they both function normally. If I put 3, the first one does not work correctly. He apparently does not pass the value he assigned to the post. As "twig break" I put 4 radio buttons, the first hidden (not working) and the other values I wanted to spend.
I have tried to change values, names and things like that, but the problem is always with the first radio button if I have more than 3.
<div class="form-group">
<label for="recipient-name" class="col-form-label">Entrada:</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="1">110V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="2">220V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="3">Automática</label>
</div>
</div>
That way, if I select the first radius of value 1, the value will not be sent to the post
<div class="form-group">
<label for="recipient-name" class="col-form-label">Entrada:</label>
<div class="radio" hidden="true">
<label><input type="radio" name="entrada" id="entrada" value="4">110V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="1">110V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="2">220V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="3">Automática</label>
</div>
</div>
That way, I hide the first button (since it does not work) and leave the others, which work normally. This practice is not ideal, in my opinion, and I have tried to copy the code of the other buttons (it's all the same) and even then the first one does not work.
Radio buttons, along with other things are inside a form with a post sending to a .php file that contains the following:
$serial = $_POST['serial'];
$marca = $_POST['marca'];
$modelo = $_POST['modelo'];
$potencia = $_POST['potencia'];
$entrada = $_POST['entrada'];
$patrimonio = $_POST['patrimonio'];
$stmt = $conn->prepare("UPDATE Nobreak SET Marca_Nobreak = '$marca', Modelo_Nobreak = '$modelo', Potencia_Nobreak = '$potencia', Cod_EntradaNoBreak = '$entrada', Patrimonio_Nobreak = '$patrimonio' WHERE Serial_Nobreak = '$serial'");
$stmt->execute();
Full Form:
<form method="POST" action="alterar.php">
<input name="tipo" type="text" class="form-control" hidden="true" id="tipo" value="nobreak">
<div class="form-group">
<label for="recipient-name" class="col-form-label">Serial:</label>
<input name="serial" type="text" class="form-control" id="serial" readonly="readonly">
</div>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Marca:</label>
<input name="marca" type="text" class="form-control" id="marca">
</div>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Modelo:</label>
<input name="modelo" type="text" class="form-control" id="modelo">
</div>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Potência:</label>
<input name="potencia" type="text" class="form-control" id="potencia">
</div>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Entrada:</label>
<!-- Sem esse input a mais ele não funciona -->
<div class="radio" hidden="true">
<label><input type="radio" name="entrada" id="entrada" value="4">110V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="1">110V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="2">220V</label>
</div>
<div class="radio">
<label><input type="radio" name="entrada" id="entrada" value="3">Automática</label>
</div>
</div>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Patrimônio:</label>
<input name="patrimonio" type="text" class="form-control" id="patrimonio">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button>
<button type="submit" class="btn btn-primary" title="Salvar">Salvar</button>
</div>
</form>