character encoding - Mail sent using PHP form showing garbled Japanese text

714
284

Answer

Solution:

I dont know why but your code works perfectly fine for me; I tried with:

<?php
$_POST['name']= 'Bob';
$name = $_POST['name'];

$_POST['email']= '[email protected]';
$_POST['message']= ' こんいちは';
echo $_POST['name'];

// Check for empty fields
if(empty($_POST['name'])        ||
empty($_POST['email'])       ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name'],'EUC-JP'));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$message = strip_tags(htmlspecialchars($_POST['message'],'EUC-JP'));
$to = '[email protected]';
$email_subject = "お問い合わせ";
$email_body = "名前: $name\n\n"."メッセージ: $message";
$headers = "From: [email protected]\r\n";
$headers .= "Reply-To: $email_address\n";
mail($to,$email_subject,$email_body,$headers);
echo 'email sent';
return true;   
?>

I suggest you to check your browser or computer language setting ;)

28

Answer

Solution:

This function will fix your issue:

$body_user = mb_convert_encoding($body_user, "UTF-8","UTF-8");
841

Answer

Solution:

I was having the same issue and solved by putting this on the top of my php file:

<!doctype html>
<?php header("Content-Type: text/html; charset=UTF-8"); ?>
<html>
<head>



People are also looking for solutions to the problem: uncaught mysqli_sql_exception
Source

Share


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

678 character encoding - Mail sent using PHP form showing garbled Japanese text
143 php - Codeigniter make sending email DRY using library or helper?
114 html - How to send an encrypted php values using php GET method
232 mysql - Issue uploading WebM files using PHP
966 html - Can I make a PHP function to create text input fields?
217 javascript - Not receiving response from php file using ajax
608 php - I want to fetch data from datetime column in this form '2015-jan-1'
718 mysql - Remaining connected to database when running php through form action
498 php - if else statement problem in phpmysql
217 cron - run php with SQL queries using crontab

People are also looking for solutions to the problem: php - error on bind_param , number of parameters in prepared statement doesn't match

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.