setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo 'Verbindingsfout: ' . $e->getMessage(); exit; } $name = isset($_POST['name']) ? (string)$_POST['name'] : ''; $message = isset($_POST['message']) ? (string)$_POST['message'] : ''; $msgName = ''; $msgMessage = ''; // form is sent: perform formchecking! if (isset($_POST['btnSubmit'])) { $allOk = true; // name not empty if (trim($name) === '') { $msgName = 'Gelieve een naam in te voeren'; $allOk = false; } if (trim($message) === '') { $msgMessage = 'Gelieve een boodschap in te voeren'; $allOk = false; } // end of form check. If $allOk still is true, then the form was sent in correctly if ($allOk) { $stmt = $db->exec('INSERT INTO messages (sender, message, added_on) VALUES (\'' . $name . '\',\'' . $message . '\',\'' . (new DateTime())->format('Y-m-d H:i:s') . '\')'); // the query succeeded, redirect to this very same page if ($db->lastInsertId() !== 0) { header('Location: formchecking_thanks.php?name=' . urlencode($name)); exit(); } // the query failed else { echo 'Databankfout.'; exit; } } } ?> Account

Account

Registreren

  • Voornaam

  • Familienaam

  • E-mail

  • Wachtwoord

  • Onthoud mijn account

  • Annuleren