Everytime I submit a form, I get nothing. It doesn't insert into database on submit and it doesn't give me any errors. I can't figure out what's wrong with it.
Code:
if(isset($_POST['submit'])) {
$email = trim($_POST['email']);
if(empty($_POST['email'])) {
$error = 'Please enter your email address.';
} else {
$newEmail = $email;
$date = date('Y-m-d H:i:s');
$insert = $db->prepare("INSERT INTO email_list(email, date) VALUES(:email, :date)");
$insert->bindParam(':email', $newEmail);
$insert->bindParam(':date', $date);
$insert->execute();
$result = $insert->execute();
if($result == false) {
$error = 'There seems to be a problem. Please try again.';
} else {
$success = 'success.';
}
}
}
?>
<div id="error"><?php echo $error; ?></div>
<div id="success"><?php echo $success; ?></div>
<form action="" type="post" enctype="multipart/form-data">
<input type="text" name="email" placeholder="Enter email address"/>
<input type="submit" name="submit" value="Notify Me"/>
</form>