I have the following PDO query and it's not working properly. When submitting a blog post twice (submit, refresh, submit), sometimes it will not process the query and save the data into my database. This is kind of a strange behavior and I have never experienced something like it. I'm used to using MySQLI so i'm not completely sure if the query is wrong or if it's something else. However, here is the code:
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$owner = $user->fetchColumn();
$title = $_POST["title"];
$content = $_POST["content"];
$is_saved = $_POST["is_saved"];
$sqlInsert = 'INSERT INTO `test` (`name`, `job`) VALUES (:name1,:job1);';
$preparedStatement = $db->prepare($sqlInsert);
$preparedStatement->execute(array(':name1' => $title, ':job1' => $content));
if($preparedStatement)
{
$LastID = $db->lastInsertId();
$success = '';
}
else
{
$error = '';
}
}
If it's not in the code, what can possible cause this?