Take the 2-minute tour ×

I am trying to use POST in Flash (ActionScript 2), to POST values to PHP mail script. I tried the PHP mail script with HTML form, and it worked perfectly fine.

But when I POST from flash and input non-English characters, I get "????" in the mail.

I tried utf8_encode($_POST["name"]), but it doesn't help.


I also tried utf8_decode($_POST["name"]), it didn't work.

Update: (So you wont have to go through all the comments)

  1. I checked the variables in Flash, the values are stored correctly.
  2. The HTML page where the Flash is embedded is UTF-8 encoded.
  3. I watched the POST headers with FireBug, the POST itself is already messed up, showing "????" instead of the real value.
  4. The the messed up "????" value, is currently url-encoded by flash, and decoded by PHP, resulting in $_POST["name"] == "???";

I suspect its the sendAndLoad method that creates the mess.


Here is the flash code:

System.useCodepage = true;
send_btn.onRelease = function() {
   my_vars = new LoadVars();
   my_vars.email = email_box.text;
   my_vars.name = name_box.text;
   my_vars.family_box = comment.text;
   my_vars.phone = phone_box.text;

if (my_vars.email != "" and my_vars.name != "") {
    my_vars.sendAndLoad("http://aram.co.il/ido/sendMail.php", my_vars, "POST");
} else {
my_vars.onLoad = function() {

    email_box.onSetFocus = name_box.onSetFocus=message_box.onSetFocus=function () {
if (error_clip._currentframe != 1) {
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Flash uses UTF8-encoding for all strings, anyway. If you use LoadVars, transfer as a urlencoded string should also work automatically.

So your problem is most probably in the PHP part of your application. For example, in order for UTF8 to work correctly, all individual PHP files must be saved in UTF8-encoded format, as well.

If just changing the file encoding doesn't work, try parsing $HTTP_RAW_POST_DATA first, check if all the fields have been transferred correctly, then go on and echo your way through until you find the place where the encoding is lost.


Here is your problem: You use System.useCodePage = true;. This requires you to specifically encode all your data as unicode before sending it. Unless you have any other documents in other encodings, and/or allow your users to upload their own text data with their localized encodings, set System.useCodePage = false;, and your utf8-problem should go away.

share|improve this answer
@weltraumpirat: Yes, but I also submitted to the same script from HTML form and it worked. I don't think there is a difference when submitting the same data to the same script, or is there? –  Dean Feb 8 '11 at 8:01
It really isn't the same unless you make sure the form sends the exact same url-encoded string as the Flash content. –  weltraumpirat Feb 8 '11 at 11:12
@weltraumpirat: I used FirePHP to check the $_POST data first thing in the script, before any other action was performed on it - it was all "???". Then I checked the POST itself (using FireBug), it appears the POSTed value is ???. All clues now point to flash, I suspect that's the culprit. –  Dean Feb 8 '11 at 12:45
@weltraumpirat: I also debugged in Flash, the values are stored correctly, it goes wrong when Flash submits the values by POST. –  Dean Feb 8 '11 at 13:22
Post the code you use to submit your data, please. –  weltraumpirat Feb 8 '11 at 16:13
show 2 more comments

If you receive data from flash you need to use utf8_decode and not utf8_encode.

Flash uses UTF8 - as long as you don't tell it to use the local characterset. And you want PHP to decode that to good old ISO-8859-1 which PHP uses internally.

You'd only use utf8_encode when preparing data for flash.

share|improve this answer
I tried to utf8_decode the $_POST values. That didn't help. –  Dean Feb 8 '11 at 12:41
Yes, from your updated code example I can see that you told flash to not use UTF-8 - but you know that already. The only thing I'd like to add is that you don't need to set useCodePage to false. That's the default value. Just leave the whole line out and the client will be all UTF8. –  Malte Köhrer Feb 8 '11 at 20:31
That's it! Thanks a lot! Please update yor answer with this info, so I can accept it, and others can easily find the solution. –  Dean Feb 9 '11 at 9:14
add comment

Your Answer


