そのため、SQL インジェクションを防ぐために PDO を使用しようとしていますが、コードを実行した後、データがデータベースに入力されません。誰かがエラーを見つけることができれば、私は非常に感謝しています.
header("location:employees.php");
$connect = mysql_connect("localhost","root","");
if(!$connect){
die(mysql_error($connect));
}
mysql_select_db("employees",$connect) or die(mysql_error());
$dbConnection = new PDO('mysql:dbname=employees;host=localhost;', 'localhost', '');
$dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$name = $_POST['name'];
$position = $_POST['position'];
$wage = $_POST['wage'];
$preparedStatement = $db->prepare('INSERT INTO employees (name, position, wage) VALUES (:name, :position, :wage)');
$preparedStatement->execute(array(':name' => $name,':position' => $position,':wage' => $wage));
mysql_query($preparedStatement);
エラーなどは発生しませんが、ユーザーがデータベースに入力されていません。