2013-10-18 27 views
0

每次我嘗試我點擊發送此錯誤出現 我收到我的郵件,但問題是,它帶我到一個錯誤頁面,而不是帶我到我指定的頁面PHP警告:無法修改標題信息 - 標題已發送(輸出開始.......在線29

這是我的代碼:!

<?php 
$errors = ''; 
$myemail = '[email protected]';//<-----Put Your email address here. 

if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) 
{ 
    $errors .= "\n Error: all fields are required"; 
} 

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email_address)) 
{ 
    $errors .= "\n Error: Invalid email address"; 
} 

if(empty($errors)) 
{ 
    $to = $myemail; 
    $email_subject = "Contact form submission: $name"; 
    $email_body = "You have received a new message. Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message"; 
    $headers = "From: $myemail\n"; 
    $headers .= "Reply-To: $email_address"; 
    mail($to,$email_subject,$email_body,$headers); 
    //redirect to the 'thank you' page 
    header('Location: thank_you.html'); 
} 

echo nl2br($errors); 
?> 

沒有空格 進出口主辦我的網站與Hostgator

+0

你是否包括來自另一個文件的用戶,誰可能已經發送了頭前? – Think

回答

3

你不能寫頭如果你已經把一些數據放到屏幕上。

頭必須在代碼的頂部,任何輸出到

相關問題