• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 508
  • Last Modified:

Japanese php contact form producing garbled emails

Hi there,

I am having difficulty building a php contact form which can handle Japanese characters.  Originally the script simply emailed the fields of the form to an address as plain text.  I was not surprised that this didn't work when Japanese characters were inserted, and so I have tried sending the form as a html email with character encoding set first to utf-8 and then to euc-jp, but neither produced the correct result.  Even when setting the encoding language within the email client to Japanese the result was garbled.  Perhaps the form itself needs to be set up in a special way?

Does anybody know of a place where I could have a look at some Japanese contact form php code to compare?

Many thanks.
0
webexpectations
Asked:
webexpectations
  • 5
  • 3
1 Solution
 
dan_272Commented:
maybe your computer doesn't have japanese chars installed, the easiest way to do it is to go to

http://www.microsoft.com/downloads/details.aspx?FamilyID=24A66277-CD9F-4332-A6F1-52B85A6470BD&displaylang=EN
 
website and download japanese language pack because word is used for outlook editing, hope this helps
by the way if this doesn't work then go to

http://www.microsoft.com/downloads/details.aspx?FamilyID=CEED31CD-15A9-4B86-AFE5-E77A095599F3&displaylang=EN

that is the japanese global IME, i think it is to do with computer problems such as above
dan
0
 
webexpectationsAuthor Commented:
Hi dan, thanks for your reply.

I'm fairly sure that I have the Japanese character pack installed, the website containing the contact form is multi-language and I can view the Japanese pages without any problem.  We believe the difficulty lies with the contact form itself, is this a possibility?
0
 
dan_272Commented:
it is possible its in the form but yeah, im not that experienced, i just know that it could be a prob with your computer, if you send me the code, i can edit it and see by sending it to my email.
that could answer the prob
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dan_272Commented:
sorry,  my email is dan_272 [at] optusnet.com.au
0
 
webexpectationsAuthor Commented:
Here is the contact form:

<FORM name=form1 action=mail.php method=post enctype=multipart/form-data>
<input name="redirect" type="hidden" id="redirect" value="thankyou.html">
<TABLE cellSpacing=2 cellPadding=2 width='100%' border=0>
  <TR class=pictures>
    <TD>&#21517;&#21069;</TD>
    <TD><INPUT class=main id=name name=name></TD></TR>
  <TR class=pictures>
    <TD>&#20250;&#31038;&#21517;</TD>
    <TD><INPUT class=main id=email name=email></TD></TR>
  <TR class=pictures>
    <TD>&#20303;&#25152;</TD>
    <TD><TEXTAREA class=main id=address name=address rows=5 wrap=VIRTUAL></TEXTAREA></TD>
  </TR>
  <TR class=pictures>
    <TD>E&#12513;&#12540;&#12523;&#12450;&#12489;&#12524;&#12473;</TD>
    <TD><INPUT class=main id=tel name=tel></TD>
  </TR>
  <TR class=pictures>
    <TD>&#12513;&#12483;&#12475;&#12540;&#12472;</TD>
    <TD><TEXTAREA class=main id=message name=message rows=4 wrap=VIRTUAL></TEXTAREA></TD>
  </TR>
  <TR class=pictures>
    <TD>&nbsp;</TD>
    <TD><INPUT class=main type=submit value=Submit name=Submit></TD>
  </TR>
</TABLE>
</FORM>

and here is the php script ('mail.php'):

<?

$to = "georgey@webexpectations.com";
$subject = "Enquiry from EJC.co.uk website (Japanese)";
$headers = "From: website@ejc.co.uk\r\n";
$headers .= "Reply-To: website@ejc.co.uk\r\n";
$headers .= "Return-Path: website@ejc.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=euc-jp\r\n";

header('Location: '. $redirect);

$content = "<html><body>";
$content .= "<h3>Enquiry form</h3>";
$content .= "Name: ".$name."<br>";
$content .= "Email: ".$email."<br>";
$content .= "Address: ".$address."<br>";
$content .= "Tel: ".$tel."<br>";
$content .= "Message: ".$message."<br>";
$content .= "</body></html>";

if ( mail($to,$subject,$content,$headers) ) {
   echo ".";
   } else {
   echo "!";
   }

?>

Any thoughts anyone?
0
 
webexpectationsAuthor Commented:
Have fixed this now.  By encoding the html email as utf-8, and encoding the language of the script itself as auto-select using notepad, I have then inserted a line of non-displayed (using style="display:none;") Japanese characters into the html email so that the email client interprets the output as Japanese even for a nearly empty form.

The headers problem was solved by using <META HTTP-EQUIV="refresh" content="0;URL=thankyou.html"> rather than header('Location: '. $redirect);.

Thank you for having a go, Dan.
0
 
dan_272Commented:
no prob man
0
 
dan_272Commented:
thankyou very much modulo, now i can ask my own questions!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now