0

我正在继续从以前的开发人员那里开发一个允许用户发送查询表单的网络。有些用户是中国人,因此他们在填写表格时倾向于使用汉字。当他们发送表格时,我收到的电子邮件会显示这个

å ‰éš†å ¡/雪兰莪州

有没有办法解决这个问题?这是代码

query_process.php:

<?php
session_start();

require_once "includes/phpmailer.php";


$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$subject = mysql_real_escape_string($_POST['subject']);
$message = mysql_real_escape_string($_POST['message']);


$subject = "[Website] Contact Form";
$body = "<p>Name: $name</p>
         <p>Email: $email</p>
         <p>Subject: $subject</p>
         <p>Message : $message</p>
        ";
        //$cf_mail_replyto
if(sendPHPMail('___', '___', '___', $subject, $body))
    echo "success";
else
    echo "fail";
?>

query_from.php:

...
function submitForm()
{
    if($("#name").val() == "")
        alert("Sorry, please fill in your name.");
        else
            if($("#email").val() == "")
        alert("Sorry, please fill in your email.");
        else
            if($("#subject").val() == "")
        alert("Sorry, please fill in your subject.");
        else
            if($("#message").val() == "")
        alert("Sorry, please fill in your message.");
    else
    {
        $.ajax({
            type: "POST",
            url: "query_process.php",
            data: $("#enquiry").serialize(),
            success: function(data){
                if(data == "success"){
                    alert("Your enquiry has been sent successfully.");
                window.location.reload();
                }
                else{
                    //console.log(data);
                    //alert(data);
                alert("There's problem sending your enquiry. Please try again later.");
                }
            }
        });
    }
}
...
</script>
//my form
...
4

1 回答 1

1
  1. 不再使用 mysql 扩展
  2. 你到底为什么在电子邮件上下文中使用 mysql_real_escape_string
  3. 您使用的是什么电子邮件查看器
  4. 函数到底是什么sendPHPMail?那是类的包装器phpmailer吗?检查Cant send email with correct characters with PHPMailer了解如何发送 UTF-8 邮件phpmailer
  5. 包含表单的 HTML 页面是否具有适当的 UTF-8 编码?
于 2013-10-11T03:30:21.277 回答