I have a form created in a page where there are two radio buttons for sex, in the following I try to do an if to know if in the bd I keep M or F, but it is as if it stayed in the value that it had before to make the update
while($fila=mysqli_fetch_array($resultados, MYSQLI_ASSOC)){
echo "<div align='center'>";
echo "<form action='cliente_actualizar_datos.php' method='get'>";
echo "<label for='identificacion'>Identificación </label> ";
echo "<input type='text' name='identificacion' value='". $fila['identificacion'] . "'><br>";
echo "<label for='nombre'>Nombre </label> ";
echo "<input type='text' name='nombre' value='". $fila['nombre'] . "'><br>";
echo "<label for='direccion'>Dirección </label> ";
echo "<input type='text' name='direccion' value='". $fila['direccion'] . "'><br>";
echo "<label for='telefono'>Teléfono </label> ";
echo "<input type='text' name='telefono' value='". $fila['telefono'] . "'><br>";
echo "<label for='correo'>Correo </label> ";
echo "<input type='text' name='correo' value='". $fila['correo'] . "'><br>";
/*echo "<label for='sexo'>Sexo </label> ";
echo "<input type='text' name='sexo' value='". $fila['sexo'] . "'><br>"; */
echo "<label id='label1' name='sexoLabel'>Sexo </label>  ";
if($fila['sexo'] == 'M'){
echo "<input type='radio' name='sexo' value='M' class='textoBlanco' checked> Masculino  ";
echo "<input type='radio' name='sexo' value='F' class='textoBlanco'> Femenino<br><br>";
}else{
echo "<input type='radio' name='sexo' value='M' class='textoBlanco' > Masculino  ";
echo "<input type='radio' name='sexo' value='F' class='textoBlanco' checked> Femenino<br><br>";
}
echo "<label for='estado_civil'>Estado Civil </label> ";
echo "<input type='text' name='estado_civil' value='". $fila['estado_civil'] . "'><br>";
echo "<div class='button'>";
echo "<button type='submit' name='submit' value='actualizar'>Actualizar</button>";
//<button type="submit" name="submit">Guardar</button>
echo "</div>";
echo "</form>";
echo "</div>";
And the one who works with the data:
$identificacion=$_GET["identificacion"];
$nombre=$_GET["nombre"];
$direccion=$_GET["direccion"];
$telefono=$_GET["telefono"];
$correo=$_GET["correo"];
//$sexo=$_GET["sexo"];
$Masculino = (isset($_GET["Masculino"]))?true:false;
if($Masculino == true){
$sexo = "M";
}
else{
$sexo = "F";
}
$estado_civil=$_GET["estado_civil"];
$conexion=mysqli_connect($db_host,$db_usuario,$db_contra,$db_nombre);
if(mysqli_connect_errno()){
echo "Fallo al conectar con la base de datos";
exit();
}
mysqli_select_db($conexion, $db_nombre) or die("No se encuentra la base de datos");
mysqli_set_charset($conexion,"utf8");
$consulta="UPDATE tbl_clientes SET nombre='$nombre',
direccion='$direccion',
telefono='$telefono',
correo='$correo',
sexo='$sexo',
estado_civil='$estado_civil'
WHERE identificacion='$identificacion'";