?
Solved

Japanese php contact form producing garbled emails

Posted on 2005-02-25
11
Medium Priority
?
496 Views
Last Modified: 2008-03-03
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
Comment
Question by:webexpectations
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 1

Expert Comment

by:dan_272
ID: 13427026
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
 

Author Comment

by:webexpectations
ID: 13428508
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
 
LVL 1

Expert Comment

by:dan_272
ID: 13437488
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
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

 
LVL 1

Accepted Solution

by:
dan_272 earned 2000 total points
ID: 13437494
sorry,  my email is dan_272 [at] optusnet.com.au
0
 

Author Comment

by:webexpectations
ID: 13441489
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
 

Author Comment

by:webexpectations
ID: 13447679
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
 
LVL 1

Expert Comment

by:dan_272
ID: 13448438
no prob man
0
 
LVL 1

Expert Comment

by:dan_272
ID: 13743468
thankyou very much modulo, now i can ask my own questions!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question