我測試一個PHP郵件的形式,很準系統一個,found here:正確編碼在PHP郵件形式字符( 「我」 變成是 「I 'm」 是)
<?php
if(isset($_POST['submit']))
{
//The form has been submitted, prep a nice thank you message
$output = '<h3>Thanks for your message</h3>';
//Deal with the email
$to = '[email protected]';
$subject = 'you have a mail';
$contactname = strip_tags($_POST['contactname']);
$adress = strip_tags($_POST['adress']);
$contactemail = strip_tags($_POST['contactemail']);
$textmessage = strip_tags($_POST['textmessage']);
$boundary =md5(date('r', time()));
$headers = "From: My Site\r\nReply-To: [email protected]";
$message = "Name: ".$contactname."\n";
$message .= "Adress: ".$adress."\n";
$message .= "E-mail: ".$contactemail."\n";
$message .= "Message: ".$textmessage."\n";
mail($to, $subject, $message, $headers);
}
?>
問題在於,每次我在郵件中寫入單引號或雙引號時,我都會收到不需要的斜槓「\」,因此「我」在我的郵箱中顯示爲「我\」。
我知道它與PHP區分代碼引號的方式只與演講引號有關,但我不知道要在表單中添加哪些內容才能使其正確運行。
任何幫助表示讚賞,
感謝傢伙它的工作 – Peanuts 2010-04-28 04:05:29