I am having this issue for days now, every SQL command (i am using PDO statements) work except INSERT INTO (i am able to SELECT and CREATE tables, but not to add data from my form into it ). I have checked and I have all the privileges that i need + i have tried all the versions of this code i could find online but nothing seems to work. Any idea? //Sorry for the pic, it's my first post and i did'nt knew.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method="post">
<input class="input" type= "text" name="nom" placeholder="nom" required> <br>
<input class="input" type= "password" name="password" placeholder="password" required><br>
<input class="button" type= "submit" value="Signup">
</form> <br>
</body>
</html>
<?php
//connessione bd
try {
$bd = new PDO("mysql:host=localhost;dbname=ems_db;charset=utf8", "root", "root");
// set the PDO error mode to exception
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
//recupero
$arr['nom'] = $_POST ['nom'];
$arr['password'] = hash('sha1', $_POST ['password']);
print_r($arr);
//
$sql = 'INSERT INTO users ( nom, password) VALUES( :nom, :password,)';
$statement = $bd->prepare($sql);
$statement->execute([
':userid' => $arr['userid'],
':nom' => $arr['nom'],
':password' => $arr['password'],
':rankid' => $arr['rankid'],
]);
$publisher_id = $bd->lastInsertId();
echo 'The publisher id ' . $publisher_id . ' was inserted';