任何想法我的代码可能有什么问题?每次有人使用国家字符(例如:ž、š、ô、í)填写我的网络表单时,PHP 脚本创建的电子邮件如下所示:
我尝试通过在标题中添加“charset=utf-8”来修复它,但这似乎不起作用。
"MÃ"ŽE BYŤ ná možnosÅ¥"
我的代码:
<?php
if($_POST['parse_var'] == "contactform"){
$emailTitle = 'Application Form';
$yourEmail = 'myMail@myMailService.com';
$nameField = $_POST['name'];
$streetField = $_POST['street'];
$cityField = $_POST['city'];
$ZIP_codeField = $_POST['ZIP_code'];
$cell_phoneField = $_POST['cell_phone'];
$emailField = $_POST['email'];
$body = <<<EOD
<br><hr><br>
Parent: $nameField <br />
Street: $streetField <br />
City: $cityField <br />
ZIP: $ZIP_codeField <br />
Mobile: $cell_phoneField <br />
Email: $emailField <br />
EOD;
$headers = "From: skola@athena-academy.sk\r\n";
$headers .= "Reply-To: $emailField\r\n";
$headers.= "Content-Type:text/html; charset=utf-8\r\n";
$success = mail("$yourEmail", "$emailTitle", "$body", "$headers");
$sent = "Your email has been sent";
}
?>