0
我有這個聯繫表單,問題是我沒有在我的郵件(šđžćč或ÁÁÁÁÁ...)中獲得特殊的字符。聯繫表格中的特殊字符
的index.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action="contactengine.php">
<label for="Name">Name:</label>
<input type="text" name="Name" />
<label for="City">City:</label>
<input type="text" name="City" />
<label for="Email">Email:</label>
<input type="text" name="Email" />
<label for="Message">Message:</label>
<textarea name="Message" rows="20" cols="20"></textarea>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>
</body>
</html>
contactengine.php:
<?php
$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "subject";
$Name = Trim(stripslashes($_POST['Name']));
$City = Trim(stripslashes($_POST['City']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
?>
我已經搜索互聯網上的解決方案,但沒有發現任何解決我的問題。 有人知道我必須插入什麼代碼嗎?
Thnx的答案,我在PHP新,所以我不知道什麼是stripslashes()。 – Edart
我刪除了stripslashes()。現在它的$ Email = $ _POST ['Email'] ;.但我沒有得到特殊字符 – Edart
對,你必須將你的電子郵件編碼設置爲UTF-8 ... 將此添加到你的第4個參數:'「從:<$EmailFrom> \ r \ n」。 「MIME-Version:1.0 \ r \ n」。 「Content-Type:text/plain; charset = utf-8」'。應該可以... – theredled