I would like to know how to insert content from a PHP form into a MySQL database. Then I show you my code and the error that appears to me.
This is the code of the form:
<?php
include 'menu.php';
?>
<br>
<form method="POST" action="ingresar1.php">
CEDULA:<input type="text" name="cedula"><br>
NOMBRE:<input type="text" name="nombre"><br>
APELLIDO:<input type="text" name="apellido"><br>
DIRECCION:<textarea name="direccion" rows="5" cols="25"></textarea><br>
EMAIL:<input type="text" name="email"><br>
TELEFONO:<input type="text" name="telefono"><br>
SEXO:<input type="radio" name="sexo" value="F">FEMENINO<br>
<input type="radio" name="sexo" value="M">MASCULINO<br>
<input type="submit" name="Ingresar" value="Ingresar">
<input type="reset" name="Limpiar" value="Limpiar">
</form>
This is the PHP code that inserts the data in the DB:
<?php
include 'conexion.php';
$sql = "INSERT INTO usuarios ('$_POST [cedula]',
'$_POST [nombre]',
'$_POST [apellido]',
'$_POST [direccion]',
'$_POST [email]',
'$_POST [telefono]',
'$_POST [sexo]')";
$resultado = mysqli_query($link,$sql);
echo mysqli_error($link);
if (!mysqli_error($link)) {
?>
<script>
alert ('Registro fue ingresado con exito');
</script>
<?php
}
else
{
?>
<script>
alert ('ERROR: El registro no fue almacenado');
</script>
<?php
}
?>
<meta http-equiv="refresh" content="10;url=ingresar.php">
After sending the data I get this:
I'll accept and I get this:
but I've seen the code and I do not know what my error might be.