現在、スパムが大量に届いています。次の行を追加しました。
if ($field_budget == "" || $field_timeline == "" || $field_email == "" || $field_name == "") {
echo "Please fill out all required form details, thank you!";
} else {
これは数週間は役に立ちましたが、今ではスパマーが戻ってきています。私のフォームを改善するためのシンプルでエレガントな方法は何ですか (以下の完全なコード)?
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_website = $_POST['cf_website'];
$field_company = $_POST['cf_company'];
$field_budget = $_POST['cf_budget'];
$field_custombudget = $_POST['cf_custombudget'];
$field_timeline = $_POST['cf_timeline'];
$field_message = $_POST['cf_message'];
$mail_to = 'sean@seanduran.com';
$subject = 'Message from a site visitor, '.$field_name;
$body_message = 'Name: '.$field_name."\n";
$body_message .= 'e-mail: '.$field_email."\n";
$body_message .= 'Website: '.$field_website."\n";
$body_message .= 'Company: '.$field_company."\n";
$body_message .= 'Budget: '.$field_budget."\n";
$body_message .= 'Custom Budget: '.$field_custombudget."\n";
$body_message .= 'Timeline: '.$field_timeline."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
if ($field_budget == "" || $field_timeline == "" || $field_email == "" || $field_name == "") {
echo "Please fill out all required form details, thank you!";
} else {
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'http://seanduran.com';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to sean@seanduran.com');
window.location = 'http://seanduran.com';
</script>
<?php
}
}
?>