看板 PHP 關於我們 聯絡資訊
<?php require_once("./phpmailer/class.phpmailer.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->Host="msa.hinet.net"; $mail->Fromm=''; $mail->FromName='阿'; $mail->AddAddress('xxxx'); $mail->CharSet='utf-8'; $mail->ContentType="text/html"; $mail->Subject='系統公告'; $mail->Body='已新增一項留言'; if ($mail->Send()) { header('Location: index.php'); } else { ?> <html> <head> <title>TITLE</title> </head> <body> fail! </body> </html> <?php } ?> 有錯誤再來 output HTML 頁面....... -- Linux is for people who want to know why it works. Mac is for people who don't want to know why it works. DOS is for people who want to know why it does not work. Windows is for people who don't want to know why it does not work. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.173.168.127
holik0123 :多謝回答,我想問一下如果在<html>上已完成,那body 07/26 02:15
holik0123 :還會被執行嗎? 07/26 02:15
bigair :你可以在 header() 下面加上 exit() 解除你的疑慮 07/26 02:18
HuangJC :簡單說,header 是產生一些資料給 Client 看,並沒有 07/26 02:46
HuangJC :Server 自己想跳往哪個網頁這種 JUMP 指令;如果有 07/26 02:47
HuangJC :JUMP,那也不必 exit 了;header 給 Client 看,exit 給 07/26 02:47
HuangJC :Server 看;而 Client 看了特定 header 是會想JUMP.. 07/26 02:48
HuangJC :廣義的說,setcookie 也動手腳在 header;而 header 名 07/26 02:48
HuangJC :為 header,所以在其上就不能先有其他資料 07/26 02:49
bigair :可參照這篇 http://0rz.tw/ec4uz 良好的習慣是重要的 07/26 02:51
HuangJC :那個網址正好在爭論題目 XD 07/26 08:13