我在页面中直接使用PHP mail()创建了一个联系人表单。它成功地通过电子邮件将te联系信息发送给收件人。但是,它不会前进到header()中标识的确认页面,并输出以下错误:
警告:无法修改标题信息-标题已由/home/redacted/redacted.com/wp-content/themes/diner/includes/theme-functions.php:752)发送。com/wp内容/主题/餐厅/页面。php在线163
关于如何解决这个问题,有什么建议或资源链接吗?
<?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST[\'contact_email\']))
{//if "email" is filled out, proceed
//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST[\'contact_email\']);
if ($mailcheck==FALSE)
{
echo "Invalid input";
}
else
{//send email
$inquirer_name = $_REQUEST[\'contact_name\'] ;
$email = $_REQUEST[\'contact_email\'] ;
wp_mail(
"[email protected]",
"Subject: Test contact",
"Name: $inquirer_name
Email: $email "
);
header("Location:http://redacted.com/contact-confirmed");
}
} else { //if "email" is not filled out, display the form ?>
<form method="post" action="http://redacted.com/contact">
<ul>
<li>First Name: <input name="contact_name" type="text" /></li>
<li>Email: <input name="contact_email" type="text" /></li>
<li><input type=\'submit\' /></li>
</ul>
<?php } ?>