联系表格中的特殊字符

时间:2012-10-29 22:06:50

标签: php special-characters contact-form

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

的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 = "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>");
?>

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

1 个答案:

答案 0 :(得分:2)

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

我认为你最好在你的php.ini中将所有magic_quotes_*设置为off(它们会添加很多“无用的”斜杠)。

相关问题