Hi
Obviously I am new to this, but I wanted to find a method to eliminate spam from my forms (without using captcha), and so have opted for a hidden field in each of the forms. I then want the PHP script to check whether the hidden field is empty- if so, process the email- if not display the error page.
I have found a script to do this, however I suspect something is not quite right as, before I added the 'if.. else if' parts into the script, the emails were being delivered in under a minute. Now, whilst they are getting through eventually- it is taking over an hour. Can someone tell me if there is something wrong with the code I am using or if there is a better way of writing it (or even if there is a better method to stop spam altogether aside from captcha). Thanks:
<?php
$Name=$POST['name'];
$Email=$POST['email'];
$Enquiry=$POST['enquiry'];
$hidden=$POST['hidden'];
$Body=<<<EOF
<h2>JO WEAKLEY PORTFOLIO Enquiry Form</h2>
<table border="0" width="70%" >
<tr>
<td width="150"><strong>NAME:</strong></td>
<td>$Name</td>
</tr>
<tr>
<td width="150"><strong>EMAIL:</strong></td>
<td>$Email</td>
</tr>
<tr>
<td width="150"><strong>ENQUIRY:</strong></td>
<td>$Enquiry</td>
</tr>
</table>
EOF;
//check if hidden field has been filled by spambot
if ($hidden == '') {
//if it is blank, send the email..
$subject="JO WEAKLEY PORTFOLIO Site Enquiry";
$to="aha_ineedsugar@hotmail.com";
$headers = "From: $Email\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $Body, $headers);
header( "Location: http://www.joweakleyportfolio.co.uk/form_response.html" );
//if it is filled, send error message..
} else {
header( "Location: http://www.joweakleyportfolio.co.uk/error.html" );
}
?>