【发布时间】:2015-05-28 14:26:35
【问题描述】:
我正在处理邮件联系表单,在我提交并刷新消息后,继续访问我的电子邮件。我该如何解决这个问题?我的代码如下。
<?php
if (isset($_POST['contact_name']) && isset($_POST['contact_email']) && isset($_POST['contact_text'])) {
$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];
if (!empty($contact_name) && !empty($contact_email) && !empty($contact_text)) {
$to = 'test@hotmail.nl';
$subject = 'Contact form';
$body = $contact_name."\n".$contact_text;
$headers = 'From: '.$contact_email;
if (mail($to, $subject, $body, $headers)) {
Echo 'Thanks for contacting me. I will be in touch soon.';
} else {
echo 'Sorry, an error occurred. Please try again later.';
}
} else {
echo 'All fields are required';
}
}
?>
【问题讨论】:
-
会话和令牌以及重定向和重新验证表单。无法击败那个组合。