I have this database created in phpMyAdmin:
The problem I have is that when I insert the data of the form where I create a user manages to connect to the database, the data sends them but does not save them, concluding with the redirection to another page.
This is my code:
<?php
$servername ="mysql.hostinger.es";
$username ="user";
$password = "pass";
$dbname = "db";
$con=mysqli_connect($servername,$username,$password,$dbname );
//check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//add details in database
if (isset($_POST['usuario']) and isset($_POST['pass'])) {
$user = $_POST['usuario'];
$pass = $_POST['pass'];
mysqli_query($con,"INSERT INTO cuentas (usuarios, clave)
VALUES ($user, $pass)");
}
header("Location: resultado.html");
?>
What is wrong? What should change? I hope you can help me with this problem.