I've already scoured StackOverflow trying to find the answer but none of the answers provided to similar questions have solved my problem.
So I have a pretty basic form here, and I want it to be able to accept Chinese characters, and then send the data in an email. (Note: Chinese characters appear on my webpage with no issue)
HTML:
<!doctype html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<link href="tour.css" rel="stylesheet">
</head>
<body>
<?php include('tour-form.php') ?>
<div class="form">
<div class="row">
<div class="container">
<br>
<form class="form-horizontal" role="form" method="post" action="tour.html">
<div class="form-group">
<label for="name" class="col-xs-2 control-label">姓名</label>
<div class="col-xs-10">
<input type="text" class="form-control" id="name" name="name" placeholder="您叫?" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
php:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$to = 'email@website.com';
$subject = 'New Form';
$body = "Customer: $name\n";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your name';
}
// If there are no errors, send the email
if (!$errName) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Form Submitted!</div>';
} else {
$result='<div class="alert alert-danger">Error!</div>';
}
}
}
?>
My code works well enough to send the email, but if I put Chinese characters in the form field, in the email they come out as really weird symbols.
Please help!!