我有一个提交表单的php文件。我输入index.html,然后将信息发送到email.php。我在提交表单后尝试重定向回index.html但是我收到错误:"警告:无法修改标题信息 - 标题已经由"
发送我尝试在php文件的每个不同行使用header("Location:http://www.mywebpage.com/index.html");
,但它还没有工作。以下是我的代码。有什么想法吗?:
<?php
$filename = "email.csv";
$exists = (file_exists($filename));
$handle = fopen($filename, 'a');
$msg = "Thank you for your appointment.\n";//EMail message
$stringToAdd=""; //File into
if (!$exists){
foreach($_POST as $name => $value) {
$stringToAdd.="$name,";
}
$stringToAdd.="\n";
$new=False;
fwrite($handle, $stringToAdd);
}
$stringToAdd="";
foreach($_POST as $name => $value) {
print "$name : $value<br>";
$msg .="$name : $value\n";
$stringToAdd.="$value,";
}
$stringToAdd.="\n";
fwrite($handle, $stringToAdd);
//now close the file
fclose($handle);
$to = $_POST["uniqname"]."@tobey.com";
$headers = "From: ". "UMSI CDO" ."<umsi.careers@tobey.com>\r\n";
mail($to, 'Appointment Scheduled', $msg, $headers); // 'Appointment Scheduled' is the subject
echo "Email sent";
?>
答案 0 :(得分:0)
在php打开标记?>
之前摆脱php结束标记<?php
和空格,html,空白行。还要检查之前是否没有输出:
header("Location:http://www.mywebpage.com/index.html");
与print
,var_dump
,echo
等相似。
答案 1 :(得分:0)
您需要删除此print "$name : $value<br>";
,因为在调用header()