PDA

View Full Version : flash and php contact form encoding problem


cressisub
01-14-2011, 01:40 PM
hi guys,

i don't know if this is the right place to post my problem but since it is a flash contact form i'll give it a try here and hope someone put me out of misery

i have a flash contact form and it works when it is filled in english. but for greek characters i get decoded symbols (ΑΛΑΞΔΛΚΗΛΚΦΔ). if someone knows how to make this php support Greek it would be great. please have a look:

<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];

if( $contact_name == true )
{
$sender = $contact_email;
$receiver = "[email protected]";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip\;
$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();

if( mail( $receiver, "Flash Contact Form - $subject", $email_body, $extra ) )
{
echo "success=yes";
}
else
{
echo "success=no";
}
}
?>

Please if someone could help me get this work?? so frustrated

iSynapps
01-14-2011, 03:45 PM
hi guys,

i don't know if this is the right place to post my problem but since it is a flash contact form i'll give it a try here and hope someone put me out of misery

i have a flash contact form and it works when it is filled in english. but for greek characters i get decoded symbols (ΑΛΑΞΔΛΚΗΛΚΦΔ). if someone knows how to make this php support Greek it would be great. please have a look:

<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];

if( $contact_name == true )
{
$sender = $contact_email;
$receiver = "[email protected]";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip\;
$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();

if( mail( $receiver, "Flash Contact Form - $subject", $email_body, $extra ) )
{
echo "success=yes";
}
else
{
echo "success=no";
}
}
?>

Please if someone could help me get this work?? so frustrated


I got some similar problem on my Flex project a while ago. Try the following:
1. Embed the greek fonts into your flash app;
2. set charset to utf-8
3. take a look here: (I can't post links so add the protocol yourself)
-> us2.php.net/manual/en/function.setlocale.php <-

Hope it helps!

audiopro
01-19-2011, 04:01 PM
You have been advised to embed the font, did you try that?

cressisub
01-19-2011, 05:27 PM
yes i have done that too. still i get some weird characters. i run out of options.
it seems that nobody's willing to solve this issue or nobody knows?? i dont buy that :s

audiopro
01-19-2011, 06:15 PM
How is the PHP script you show interfaced with Flash?

Nekkam
01-27-2011, 05:20 PM
try this
$charset=utf-8

mike007
02-22-2011, 07:52 PM
How does the POST work from Flash to PHP? I know how to use GET but I do not know how to tell flash to data to a php script using post. And how do you get a response back in from from php?

iSynapps
02-22-2011, 07:59 PM
use this

private var request:URLRequest = new URLRequest('you-PHP-script');
private var loader:URLLoader = new URLLoader();
private var vars:URLVarialbles = new URLVariables();

// Pass the data through vars. you can name the property whatever you want (ex.: vars.myItem)
vars.itemName = 'Post 1';
vars.someMore = 'Post 2';

request.method = URLRequestMethod.POST;
request.data = vars;

// add PROGRESS, IOError, SecurityError and COMPLETE listeners (if you must)
loader.addEventListener(Event.COMPLETE, yourHandlerHere);

loader.load(request);

mike007
02-22-2011, 08:09 PM
Awesome. Thanks for this.

use this

private var request:URLRequest = new URLRequest('you-PHP-script');
private var loader:URLLoader = new URLLoader();
private var vars:URLVarialbles = new URLVariables();

// Pass the data through vars. you can name the property whatever you want (ex.: vars.myItem)
vars.itemName = 'Post 1';
vars.someMore = 'Post 2';

request.method = URLRequestMethod.POST;
request.data = vars;

// add PROGRESS, IOError, SecurityError and COMPLETE listeners (if you must)
loader.addEventListener(Event.COMPLETE, yourHandlerHere);

loader.load(request);

mike007
02-23-2011, 05:31 PM
I got your code to work on my script. However, then I have an echo, print, or return on PHP, how do I show that value in my app?

use this

iSynapps
02-23-2011, 11:37 PM
read the data property of the target:


private function sampleComplete (e:Event) : void
{
// PHP echo
trace(e.target.data);
}

iSynapps
02-26-2011, 03:35 AM
@cressisub
I don't know what charset you're using but you can try to transform everything to entities:

$contact_message = htmlentities($_POST['message']);