I have an html for registering users in a system (signup.html), and with a form I send the data to a PHP that executes a query to save them in the database (signup.php), but when I review the table where the record should be saved there is nothing.
This is my form (signup.html):
<form action="signup.php" method="post" id="form_login" >
<div class="form-group has-feedback">
<input name="name" type="text" id="name" class="form-control" placeholder="Nombre(s)" >
<input name="lastname" type="text" id="lastname" class="form-control" placeholder="Apellido(s)" >
<span class="fa fa-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input name="username" type="text" id="username" class="form-control" placeholder="Nombre de usuario" >
<span class="fa fa-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input name="password" type="password" id="password" class="form-control" placeholder="Contrase単a">
<span class="fa fa-lock form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input name="password" type="password" id="confirm_password" class="form-control" placeholder="Confirmar contrase単a">
<span id="span_contrasena" class="fa fa-lock form-control-feedback"></span><br id="br">
</div>
<div class="row">
<div class="col-4">
<button type="submit" name="Submit" id="enviar" class="btn btn-primary btn-flat">Finalizar registro</button><br><br>
</div>
</div>
</form>
This is the PHP that receives it and executes the query (signup.php):
require_once("../db_con.php");
$pass = password_hash($_POST['password'], PASSWORD_DEFAULT);
$sql = "INSERT INTO usuarios (usuario, nombre, apellido, pass) VALUES ( :usuario, :nombre, :apellido, :pass )";
$pdo_statement = $pdo_conn->prepare( $sql );
$result = $pdo_statement->execute( array( ':usuario'=>$_POST['username'], ':nombre'=>$_POST['name'], ':apellido'=>$_POST['lastname'], ':pass'=>$pass ) );
if (!empty($result) ){
echo "lelel";
//header('location:../index.html');
}
else{
echo "No se guardo el registro<br/>";
print_r($pdo_conn->errorInfo());
}
And this is the PHP for the connection to the BD:
try{
$hostname = "Localhost";
$username = "aabdesig_admin";
$password = "aabdesign2018";
$database = "aabdesig_registros";
$pdo_conn = new PDO( 'mysql:host=Localhost;dbname=aabdesig_registros', $username, $password );} catch (PDOException $e) {
print "¡Error!: " . $e->getMessage() . "<br/>";
die();
}
When I check PHP in the browser, this is what it prints:
The record was not saved
Array ([0] = > 00000 [1] = > [2] = >)
Check about that PDO error and it says that this array comes out when everything was executed correctly but even then the record is not in my DB.
Thank you in advance for your answers.