A
Anonymous
May 26, 2009
Answered
Loading php output into flash to determine message
- May 26, 2009
- 1 reply
- 1191 views
Hi there,
I am using the following tutorial to create a php message page, however, even in their example, I cannot get the php echo function to send the output to the dynamic text fields: http://www.sephiroth.it/tutorials/flashPHP/email/index.php.
Here is the button code to send the php variables and attempt to capture the php echo of either "sent" or "error"
on (release) {
// Now import the variables we
// need to send in this movie clip
sender_mail = _root.Semail.text
sender_name = _root.Sname.text
sender_subject = _root.Ssubject.text
sender_message = _root.Smessage.text
// all the vars we just imported
// will be sent via POST method now
loadVariables("sendmail.php",this,"POST");
// and when receives the answer from
// the server...
this.onData = function()
{
// ok, next frame
_root.nextFrame();
if(this.output=='sent')
{
// in case of success
_root.errTitle = 'Thank You.';
_root.errType = "Your message has been succesfully sent.";
} else {
// else
_root.errTitle = "Error!";
_root.errType = "Attention, an error occurred. Please try again later.";
}
}
}
Here is the php which should echo the "sent" or "error"
<?
if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']))
{
$to = "email@website.com";
$subject = stripslashes($HTTP_POST_VARS['sender_subject']);
$body = stripslashes($HTTP_POST_VARS['sender_message']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";
if(@mail($to, $subject, $body, $header))
{
echo "output=sent";
} else {
echo "output=error";
}
} else {
echo "output=error";
}
?>
The email does send fine, but it does not show the message which lets the user know the status of the message. Any ideas? There is a link to download the .zip file of the tutorial - I have attached it here.