I put together a simple PHP email form for a website, but it keeps sending blank emails every so often. Most of the the fields are "required" and I was using a captcha system for a while, but the blank emails kept coming.
HTML markup:
<form action="mail_send.php" method="post">
<input name="name" type="text" required="required" size="40" />
<input name="email" type="text" required="required" size="40" />
<input name="company" type="text" size="40" />
<textarea name="message" cols="80" rows="7" required="required"></textarea>
<input type="submit" value="Submit" />
</form>
PHP:
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$message = $_POST['message'];
$formcontent=" FROM:
$name
COMPANY:
$company
MESSAGE:
$message";
$recipient = "email address";
$subject = "Subject";
$mailheader = "From: $email
";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "<script>window.location = 'confirmation.php'</script>";
Everything works fine when I test it, I receive the emails from the form with no problems at all, but for some reason I keep getting blank emails often (possibly from robots).
Any ideas?
Thanks!