I am changing all mysqli queries to use PDO now and just want to make sure I'm doing it right. Here is an old one:
$sql = "INSERT into profile (profileid, name, description) values ('$profileid', '$name', '$description')";
$sql= mysqli_query($connection,$sql);
if (!$sql) {
die("Database query failed: " . mysqli_error($connection));
} else {
redirect_to('/my-account');
}
And here is how I rewrote it:
$stmt = $pdo->prepare("INSERT into pools (profileid, name, description) values (:profileid, :name, :description)");
$stmt->execute([':profileid' => $profileid, ':name' => $name, ':poolname' => $poolname, ':description' => $description]);
redirect_to('/my-pools');
It seemed to work fine when I tested, just want to make sure I did EVERYTHING right. Does it all look good?
Also, prior to my old mysqli query, I would do this to "sanitize" the data:
$description = mysqli_real_escape_string($connection,$_POST['description']);
With PDO, I do NOT have to have that AT ALL anymore, is that correct? Just want to confirm before I delete all the escaping stuff from my code after switching to PDO.