Jump to content

PHP and Flash


whats_her_name

Recommended Posts

I have an email form in Flash and my action script is as follows:

 

on (release) {
//create the LoadVars objects which will be used later
var dataSender:LoadVars = new LoadVars();   //one to send data...
var dataReceiver:LoadVars = new LoadVars(); //and one to catch what comes back
var targetPHP = "processEmail.php?now="+getTimer();

//final check to make sure fields are completed
if (_parent.Sname.text != '' &&
    _parent.Semail.text != '' &&
     	_parent.Smsg.text != '') {

	_parent.alert_txt.text='';//clear any previous error messages or warnings
	//advance playhead to frame 2 - the "processing" message
	_parent.gotoAndPlay(2);

	//assign properties to LoadVars object created previously
	dataSender.sender_name = _parent.Sname.text;
	dataSender.sender_email = _parent.Semail.text;
	dataSender.sender_subject = 'A Message from melrosenorth.ca';
	dataSender.sender_message = _parent.Smsg.text;

	//callback function - how to handle what comes back
	dataReceiver.onData = function() {
		if (dataReceiver.output == 'sent') {
			_parent.gotoAndPlay(4);
		} else if (dataReceiver.output == 'error') {
			_parent.gotoAndPlay(3);
		} else {
			_parent.gotoAndPlay(1);
			_parent.alert_txt.text = 'No output received.';
		}
	}

	dataSender.sendAndLoad(targetPHP, dataReceiver, "POST");
	//dataSender.sendAndLoad("processEmail.php", dataReceiver, "POST");

} else {
   	//warning if user tries to submit before completing form
_parent.alert_txt.text = "Please complete all fields.";
   }   
}

 

My PHP to send the email is as follows:

<?

$to="mytestemail@mytestemail.com"; //of course, this is a real email address in my environment...

//create short variable names
$s_name=trim($_POST['sender_name']);
$s_email=trim($_POST['sender_email']);
$s_subject=stripslashes($_POST['sender_subject']);

$body=stripslashes($_POST['sender_message']);
$body .= "\n\n--------------------\n";
$body .= "Mail sent by: $s_name <$s_email>\n";

$header = "From: $s_name <$s_email>\n";
$header .= "X-Mailer: PHP/" .phpversion() ."\n";
$header .= "X-Priority: 1";


if (mail($to, $s_subject, $body, $header)) {
echo 'output=sent';
} else {
echo 'output=error';
}

?>

 

All I get is the "No output received" message in my flash form.  What is wrong???

 

THANK YOU!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.