1 Hi, I have a problem inserting data from php to mysql. I create the connection and insert it, I do not know if it is the database. I'm working with WAMP.
How about. in my case I use PDO.
to make the insertion. This is an example.
<?php
include_once "conexion.php";
if(isset($_POST)){
if(isset($_POST['name']) &&
isset($_POST['last_name']) &&
isset($_POST['email']) &&
isset($_POST['password'])){
$nombre = $_POST['name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$password = $_POST['password'];
//Ejecutar una sentencia preparada vinculando varialbes de PHP
$gsent = $pdo->prepare('INSERT INTO users (name, last_name, email, password)
VALUES (:name,:last_name,:email,:password)');
$gsent->bindParam(':name', $nombre, PDO::PARAM_STR);
$gsent->bindParam(':last_name', $last_name, PDO::PARAM_STR);
$gsent->bindParam(':email', $email, PDO::PARAM_STR);
$gsent->bindParam(':password', $password, PDO::PARAM_STR);
$state= $gsent->execute();
if($state){
echo 'Datos ingresados';
}
else{
echo 'Datos NO Ingresados';
}
$pdo= null;
}
}
?>
Where you include your connection.
where $state
returns as boolea.
If it still does not solve your doubt. I invite you to revices the documentation of PHP mysql
Greetings