Link to home
Start Free TrialLog in
Avatar of webexpectations
webexpectations

asked on

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.
Avatar of dan_272
dan_272

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
Avatar of webexpectations

ASKER

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?
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
ASKER CERTIFIED SOLUTION
Avatar of dan_272
dan_272

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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.
no prob man
thankyou very much modulo, now i can ask my own questions!