我一直在尝试实施服务器验证以防止在我的联系我们页面中出现空白电子邮件,但我不确定如何在 PHP 中执行此操作,这是我的代码:
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_tel = $_POST['cf_tel'];
$field_message = $_POST['cf_message'];
$mail_to = 'test@test.com, test@test.com, test@test.com';
$subject = 'Just iStuff Mobile Contact Us: '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Telephone Number: '.$field_tel."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for your email, we have received your message and will reply within the next few days.');
window.location = 'contactus.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed, please try again or email test@test.com');
window.location = 'contactus.html';
</script>
<?php
}
?>
任何人都可以帮我做到这一点,在线教程不包括这种方式......
谢谢