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="[email protected]"; //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
https://forums.phpfreaks.com/topic/45791-php-and-flash/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.