(A late answer, but could prove to be useful down the road).
Generally, SPAMBOTS will look for a form element called email
or contact
or any visible input they can put their little spammy hands on.
What you could do is to show/mark an input stating "If you're human, DO NOT fill this".
For example:
If you're human, DO NOT fill this: <input type="text" name="email">
then check if the field is not empty
. If it is not empty and (most likely) filled in by the SPAMBOT, then make it die();
or redirect.
For example: and using an if(isset...
from a named submit button:
<input type="submit" name="soobmeet" value="Send">
Sidenote: I chose "soobmeet" because it's generally not a good idea to name it "submit" etc.
(Something I learned recently from one the BIG GUNS here on SO)
PHP
<?php
if(isset($_POST['soobmeet'])){
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email1 = $_POST ['email1'];
$phone = $_POST ['phone'];
$comments = $_POST ['comments'];
$email = $_POST ['email'];
if(!empty($_POST['email'])){
header("Location: get_lost.html");
// or make it die();
}
else{
$headers = "MIME-Version: 1.0\r\n";
$headers = "From: $email1";
$to = 'email@example.com';
$subject = 'Contact Form Submitted - Virginia Subsite';
$message = "
First name: $firstname \n
Last name: $lastname \n
Email: $email1 \n
Phone: $phone \n
Comments: $comments \n";
mail($to, $subject, $message, $headers);
header("Location: thankyou.html");
}
}
?>