I am continuing to developing a web from previous developer that allow user to sent query form. Some of the user is Chinese therefore they tend to use Chinese character when they fill the form. When they sent the form,the email I receive will show this
å ‰éš†å ¡/雪兰莪州
Is there anyway to solve this problem? Here is the code
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
...
sendPHPMail
function? Is that a wrapper for the phpmailer
class? Check Cant send email with correct characters with PHPMailer on how to send UTF-8 mail with phpmailer
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.