We help IT Professionals succeed at work.

PHP echo using for Zen Cart 1.3.7 Contact Us coding change

questions1979
on
Medium Priority
771 Views
Last Modified: 2012-08-14
Hi all,

I had a big problems while my customers using the "Contact Us" form to send the questions to us include Chinese, Japanese or Koren Text.

Since Zen Cart 1.3.7 are encode by ISO 8859-1, not using UTF-8 and the MySQL Database Collection are using latin_swfish_1, also not UTF-8

So change the header to UTF-8 total maybe will broke the all site.

So now I reading the "Contact Us"'s PHP code, find it control by this file
/includes/templates/template_default/templates/tpl_contact_us_default.php

and I find by Google, have a tag called accept-charset="UTF-8" for the form tag ...

So I want to make a try, but I am not a programmer, try add this tag to the original PHP code failed

The Original Code here
<?php echo zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US, 'action=send')); ?>

and it will display this XHTML output

<form name="contact_us" action="http://www.rctoplist.com/testegrm/contact_us.html?action=send" method="post">

How to make the change to the PHP code that can add the accept-charset="UTF-8", then the XHTML output to be like that

<form name="contact_us" action="http://www.rctoplist.com/testegrm/contact_us.html?action=send" method="post" accept-charset="UTF-8">

Thank you very much.
Comment
Watch Question

Richard QuadlingSenior Software Developer
CERTIFIED EXPERT

Commented:
From my understanding, you cannot cram the Japanese/Chinese/etc, characters into a codepage.

So, you would have to take the binary string of data received (using the current encoding) and convert it to a base36 string. This should be easily reversible to show back to the user.

In terms of modifying the <form> tag, you can either modify the function or use a simple string function to add the accept-charset attribute.


<?php
$s_Form = zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US, 'action=send'));
$s_Form = '<form accept-charset="UTF-8"' . substr($s_Form, 5);
 
?>

Open in new window

Senior Software Developer
CERTIFIED EXPERT
Commented:
Having just looked at the code for zen_draw_form, you could modify the template too ...
<?php echo zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US, 'action=send'), 'post', 'accept-charset="UTF-8"'); ?>

Open in new window

Explore More ContentExplore courses, solutions, and other research materials related to this topic.