我的问题是,当我使用联系表单发送泰语时,编码变得非常奇怪,当我收到电子邮件时。但英语不会发生这种情况。 通常,泰语对网站使用TIS-620编码,所以我也把它放在页面的标题中。
这是我使用联系表单收到的电子邮件:
姓名:א× ° · ל · ¹¹·ל电子邮件:melo6767@hotmail.com电话: 0811234472消息:¤ ¼ ¼י ¹ ל טב י ב ¨ ÷ א ט §¤ט ד×י¨ט ב א ט §' ה«¹ל ···· 电子邮件הט¤ט'
我无法弄清楚要做什么,因为我对PHP一无所知。 请帮忙。
这是我的联系表格编码
<div class="contactform">
<?php
if (isset($_REQUEST['email'])){
$mailcheck = spamcheck($_REQUEST['email']);
if (($mailcheck==FALSE) || (!$_REQUEST['name']) || (!$_REQUEST['subject'] || (!$_REQUEST['message']))){
if(isset($_POST['name'])){
$name = $_POST['name'];
}
if (isset($_POST['email'])){
$email = $_POST['email'];
}
if (isset($_POST['phone'])){
$phone = $_POST['phone'];
}
if (isset($_POST['subject'])){
$subject = $_POST['subject'];
}
if (isset($_POST['message'])){
$message = $_POST['message'];
}
$form = "<div class=\"indent\"><form method=\"post\" action=\"contactus.php?pg=5\">";
$form .= "<p class='textred indent'>Name / ชื่อ-นามสกุล * </p>";
$form .= "<input name=\"name\" type=\"text\" value=\"".htmlentities($name)."\" />";
$form .= "<br />";
$form .= "<p class=\"textred indent\">Email / อีเมล * </p>";
$form .= "<input name=\"email\" type=\"text\" value=\"".htmlentities($email)."\"/>";
$form .= "<br />";
$form .= "<p class=\"indent\">Phone / เบอร์โทรศัพท์ </p>";
$form .= "<input name=\"phone\" type=\"text\" value = \"".htmlentities($phone)."\" />";
$form .= "<br />";
$form .= "<p class=\"textred indent\">Subject / หัวข้อ * </p>";
$form .= "<input name=\"subject\" type=\"text\" value = \"".htmlentities($subject)."\" />";
$form .= "<br />";
$form .= "<p class=\"textred indent\">Message / ข้อความ * </p>";
$form .= "<textarea name='message' rows='17' cols='46'>".htmlentities($message)."</textarea><br />";
$form .= "<img src=\"captcha.php\" id=\"captcha\" /><br/>
<a href=\"#\" onclick=\"
document.getElementById('captcha').src='captcha.php?'+Math.random();
document.getElementById('captcha-form').focus();\"
id=\"change-image\"><p style='font-size:12px;'>Change text.</p></a><br/>
<p class='textred indent'>Enter code above*</p>
<input type=\"text\" name=\"captcha\" id=\"captcha-form\" autocomplete=\"off\" /><br/>
<input type='submit' />
</form> <p class='textred'>*Please provide the necessary details. กรุณาใส่ข้อมูลให้ถูกต้อง</p></div>";
echo $form;
}else{
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$toEmail = 'info@culfix.com';
$messageBody = "Name: ". $_REQUEST['name']. "\n";
$messageBody .="Email: ". $_REQUEST['email']. "\n";
$messageBody .="Phone: ". $_REQUEST['phone']. "\n";
$messageBody .="Message: ". $_REQUEST['message']. "\n";
$mailHeader = "From: ". $_REQUEST['email']."\r\n";
$mailHeader .= "Reply-To: ". $_REQUEST['email']."\r\n";
mail($toEmail, $subject, $messageBody, $mailHeader);
header("Location:email.php?pg=5");
ob_end_finish();
}
}else{
echo "<div class=\"indent\">
<form method='post' action='contactus.php?pg=5'>
<p class=\"indent\">Name / ชื่อ-นามสกุล * </p>
<input name='name' type='text' />
<br />
<p class=\"indent\">Email / อีเมล * </p>
<input name='email' type='text' />
<br />
<p class=\"indent\">Phone / เบอร์โทรศัพท์ </p>
<input name='phone' type='text' />
<br />
<p class=\"indent\">Subject / หัวข้อ * </p>
<input name='subject' type='text' />
<br />
<p class=\"indent\">Message / ข้อความ *</p>
<textarea name='message' rows='17' cols='46'></textarea><br />
<div class='indent'><img src=\"captcha.php\" id=\"captcha\" /></div>
<a href=\"#\" onclick=\"
document.getElementById('captcha').src='captcha.php?'+Math.random();
document.getElementById('captcha-form').focus();\"
id=\"change-image\"><p style='font-size:12px;'>Change text.</p></a><br/>
<p class='indent'>Enter code above</p>
<input type=\"text\" name=\"captcha\" id=\"captcha-form\" autocomplete=\"off\" /> <br/>
<input type='submit' />
</form></div>";
}
?>
</div>
答案 0 :(得分:0)
尝试设置表单的 enctype 属性<form enctype="application/x-www-form-urlencoded;charset=UTF-8">
。
而不是“UTF-8”,设置“TIS-620”,看看是否能解决您的问题。