Hi guys, I have recently started using some PHP. I have got my form working but I am worried about spammers exploiting my form. There are 2 things that I would like some help with.
1: How can I "spam proof" my form.
2: How can I limit the input in the number field to be only numbers and no letters or other characters.
Here is my code:
<?php
$recipient = 'xxxx@xxxx.com';
$subject = stripslashes($_REQUEST['busname']);
$from = stripslashes($_REQUEST['name']);
$number = stripslashes($_REQUEST['number']);
$town = stripslashes($_REQUEST['city']);
$state = stripslashes($_REQUEST['state']);
$hearabout = stripslashes($_REQUEST['hearabout']);
$email = stripslashes($_REQUEST ['emailadd']);
$messageinfo = stripslashes($_REQUEST['messageinfo']);
$subscribe = stripslashes ($_REQUEST['subscribe']);
$msg = "From: $from\nPhone: $number\nEmail: $email\nLocation: $town, $state\nHow did you hear about us? $hearabout\nSubscribe: $subscribe\n\n $messageinfo";
if (empty($subject) || empty($from) || empty($number) || empty($town) || empty($state) || empty($hearabout) || empty($email) || empty($messageinfo) || empty($subscribe)) {
header( "Location: http://www.xxxx.com/error.html" );
}
else { mail($recipient, $subject, $msg);
header( "Location: http://www.xxxx.com/thankyou.html" );
}
?>
Any help would be greatly appreciated.