2017-07-11 158 views
3

如何通過send_mail.php發送此郵件後,直接將頁面直接轉到另一個感謝頁面,該頁面名稱爲tack.php,該結構與此郵件位於同一位置.inc.php文件?謝謝頁面後表格不顯示

<?php header("Content-Type: text/html; charset=utf8"); 
function mail_file($to, $from, $subject, $body, $file) { 
    $boundary = md5(rand()); 
    $headers = array(
     'MIME-Version: 1.0', 
     "Content-Type: multipart/mixed; charset=UTF-8; boundary=\"{$boundary}\"", 
     "Content-Transfer-Encoding: 8bit", //Nytt 170711 
     "From: {$from}" 
    ); 
    $message = array(
     "--{$boundary}", 
     //'Content-Type: text/HTML; charset=iso-8859-1', 170707 
     'Content-Transfer-Encoding: quoted-printable', 
     '', 
     quoted_printable_encode($body), // Här är nya innehåll kodat som quoted-printable istället. 
     '',        // Kommer orsaka en extra radbrytning efter meddelandet. 
     "--{$boundary}", 
     "Content-Type: {$file['type']}; name=\"{$file['name']}\"", 
     "Content-Disposition: attachment; filename=\"{$file['name']}\"", 
     "Content-Transfer-Encoding: base64", 
     '', 
     chunk_split(base64_encode(file_get_contents($file['tmp_name']))), 
     "--{$boundary}--", 
     '', 
    ); 
    mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers)); 
} 
?> 
+1

不要發送一個Content-Type頭,而是在函數調用後發送一個Redirect頭。 – jeroen

+0

你能告訴我你的意思嗎? :) –

+0

刪除你的第一個頭文件:「php header(」Content-Type:text/html; charset = utf8「);」你不需要它,因爲你不應該返回任何東西 –

回答

3

添加的頭在你的代碼的末尾:

header('Location: http://www.example.com/thank_you.php'); 

將用戶重定向到指定的頁面

編輯:

同時刪除您的第一個標題:

php header ("Content-Type: text/html; charset=utf8"); 

你不需要它,因爲你不應該返回任何東西

+1

嘗試在你的函數「mail_file」的調用後添加頭文件 –

+0

我認爲它的工作原理! :) 現在只有一個問題。我的Android手機上的Gmail會帶有問號標誌。 Hotmail沒問題,在webmail上都可以。任何人? –

+0

也許charset錯誤,但:ÅÄÖ? –