我最近剛到的服務器,因爲我做了我的PHP的聯繫表格已經有點歪斜,WIFF。PHP聯繫表重定向錯誤
它工作正常,作爲一個接觸的形式,而是重新定向功能將不復存在。
我得到了重新定向頁面上此錯誤:
警告:不能更改頭信息 - 已經 發送頭(輸出開始/家庭/內容/11511973分之73/ HTML /接觸。 PHP:14) /home/content/73/11511973/html/contact.php上線20
這裏是我的contact.php代碼:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Order/Enquiry';
$to = '[email protected]';
$subject = "From: ".$_POST['name'];
$body = "From: $name\nE-Mail: $email\n\nMessage:\n\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p><center><br><img src="images/cat.jpg"><br><br><br><font size="4" face="Tw Cen MT">Your message has been sent! You will now be redirected to the home page.<br><br>Thank you for your message!</font></center></p>';
} else {
echo '<p><center><br><img src="images/cat.jpg"><br><br><br><font size="4" face="Tw Cen MT">Something went wrong, go back and try again! You will now be redirected to the home page.</font></center></p</p>';
}
}
header('Refresh: 3; url=index.html')
?>
這裏是我的網站,在全動作的網頁:
www.crookedcartoon.co.uk/contact.html
謝謝 -Alex
使用'標題(「位置:index.html的」);',而不是'頭('Refresh:3; url = index.html')'。另外,您的'header'('Refresh:3; url = index.html')'末尾沒有關閉';'。 –
此外,您收到錯誤消息(*「無法修改標題信息」*)的原因可能是PHP,HTML或臭名昭着的BOM字節順序標記之間的空白造成的。其中一個原因會導致這種情況。 –