我已經在PHP中創建了一個聯繫表單。表單工作正常,併發送消息,但當我嘗試將用戶重定向到我的謝謝頁面時,我收到一個頭文件已發送消息。提交後重定向表單感謝頁面
我開始形式:
<form name="myform" id="myform" class="form-foot" action="/receiving.php" method="post">
而對於receiving.php的PHP代碼:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
if(isset($_POST['submit']))
{
$from_add = "[email protected]";
$to_add = "[email protected]";
$subject = "Contact Form";
$message = "
Name:$name \n
Email: $email \n
Message: $message \n
$headers = "From: $from_add \r\n";
$headers .= "Reply-To: $from_add \r\n";
$headers .= "Return-Path: $from_add\r\n";
$headers .= "X-Mailer: PHP \r\n";
if(mail($to_add,$subject,$message,$headers))
{
Header("Location: /thanks");
}
}
?>
我怎樣才能將用戶重定向到成功提交後www.mysite.com/thanks?
下面是解http://stackoverflow.com/questions/4459204/seeing-cannot-modify-header-information-error-when-attempting-to-redirect – Kevin
當你去完成通過重複你可能想要讀一些關於頭部注入的主題 – PeeHaa