E Fixed error "undefined index" with if, what happens is that I save empty data now in the database, without if I get error and just the empty guard, see something I do not? help please .............
This is the form, the select is nothing more than a combo that I have ..
<?php
include('conexion.php')
?>
<body>
<form action="guarda_usuario.php" method="post" enctype="text/plain">
<h1>CONTACTO</h1>
<input type="text" placeholder="Escribe tu nombre" name="nombre" id="" <br>
<input type="text" placeholder="Escribe tu apellido" name="apellido" id=""> <br>
<input type="email" placeholder="Escribe tu email" name="email" id="" > <br>
<textarea placeholder="Escriba su comentario" name="comentario"></textarea> <br>
<select style="width:200px" name="juego" >
<option value="0">Selección:</option>
<?php
$query = $mysqli -> query ("SELECT * FROM productos");
while ($valores = mysqli_fetch_array($query)) {
echo '<option value="'.$valores[id].'">'.$valores[producto].'</option>'; } ?>
</select> <br> <br>
<input type="submit" value="ENVIAR" name="" id="boton">
</form>
This is my code to enter data into the database
<?php
include('conexion.php');
?>
<?php
if (isset($_POST['nombre'])) {
$nombre = $_POST['nombre'];
} else {
$nombre = "";
}
if (isset($_POST['apellido'])) {
$apellido = $_POST['apellido'];
} else {
$apellido = "";
}
if (isset($_POST['email'])) {
$email = $_POST['email'];
} else {
$email = "";
}
if (isset($_POST['producto'])) {
$producto = $_POST['producto'];
} else {
$producto = "";
}
if (isset($_POST['comentario'])) {
$comentario = $_POST['comentario'];
} else {
$comentario = "";
}
$query="INSERT INTO usuarios (nombre, apellido, email, producto, comentaro) VALUES ('$nombre','$apellido','$email','$producto', '$comentario' )";
$resultado=$mysqli->query($query);
?>