I have a form connected to MySQL but when I enter the information it does not register and it does not save it in MySQL. This is the code in PHP:
<?php
Include 'conexion.php';
$nombre=$_POST["nombre"];
$apellido=$_POST["apellido"];
$correo=$_POST["correo"];
$contraseña=$_POST["contraseña"];
$telefono=$_POST["telefono"];
//Consulta para insertar
$insertar ="INSERT INTO tarjetas(nombre, apellido, correo, contraseña, telefono)
VALUES ('$nombre','$apellido','$correo','$contraseña','$telefono')";
$verificar_correo =mysqli_query($conexion, "SELECT * FROM tarjetas WHERE correo='$correo'");
$resultado=mysqli_query($conexion,$insertar);
if (!$resultado) {
echo "Error al registrar";
}else {
echo "Registro guardado ";
}
//Cerra conexion
mysqli_close($conexion);
?>
I think the problem is in the SQL statement but I do not know what is wrong. : 'v
And this is the HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Estilos -->
<link rel="stylesheet" href="css/style.css">
<title>Hello, world!</title>
</head>
<body>
<h1>Plantilla</h1>
<form action="php/registrar.php" method="post" class="form-register" onsubmit="return validar();">
<h2 class="form_titulo">Introduzca sus datos</h2>
<div class="contenedor-inputs">
<input type="text" name="nombre" id="nombre" placeholder="Nombre" class="input-48">
<input type="text" name="apellido" id="apellido" placeholder="Apellido" class="input-48">
<input type="email" name="correo" id="correo" placeholder="Correo" class="input-100">
<input type="password" name="contraseña" id="contraseña" placeholder="contraseña" class="input-48">
<input type="tel" name="telefono" id="telefono" placeholder="Telefono" class="input-100">
<input type="submit" name="enviar" id="enviar" value="enviar" class="btn_enviar">
</div>
</form>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Optional JavaScript -->
<script type="js/validar.js"></script>
</script>
</body>
</html>