0

我有这个联系表,但问题是我的邮件中没有特殊字符(šđžćč 或 ÀÁÂÃÄÅ...)。

索引.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>

联系引擎.php:

<?php
$EmailFrom = "example@example.com";
$EmailTo = "example@example.com";
$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>");
?>

我在互联网上搜索了解决方案,但没有找到任何解决我的问题的方法。有人知道我必须插入什么代码吗?

4

1 回答 1

2

stripslashes()破坏 UTF-8 特殊字符。

我认为你最好magic_quotes_*在你的 php.ini 中全部关闭(它们添加了很多“无用的”斜杠)。

于 2012-10-29T22:13:18.177 回答