PDA

View Full Version : PHP, flash email, and retuning values


Brayshakes
05-23-2005, 09:36 PM
I am trying to write a relativly simlpe email PHP script that takes input from my flash and sends an email to someone. So I did that but my problem resides in the fact that I want flash to detect if the message was sent and return a value. But since PHP was server side is there anyway that I can return a value to flash from PHP?

on (release){
getURL ("mail.php", "", "POST");
}


and the php code is this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
$to = "jim@oddparts.net \n";
$subject = "Mail from $_POST['name'] @ oddparts.net \n";
mail ('jim@oddparts.net', '$to', '$subject', '$_POST['input']');

<body>
</body>
</html>

Flash Gordon
05-23-2005, 09:40 PM
use sendAndLoad of the LoadVars . It is a built in feature. Search the the forums a bit. It is pretty easy to use.

Brayshakes
05-23-2005, 10:09 PM
Well that solves my flash problem but how do I get php to have that returned string available? Like is there a return function where I can return a string after I execute the mail() module?

cancerinform
05-23-2005, 10:47 PM
In the action frame where you have the clip from where you send the data to PHP put this script:

_root.onData = function() {
if (this.result == "Okay") {
nameofclip.gotoAndPlay("Success");
}
}


In the php script after your main function add this after your function:

print "&result=Okay";
exit;

However, make sure when you send out the php script that the data will be sent back to the _root by adding 0.

on (release){
loadVariablesNum ("mail.php", 0, "POST");
}


There are some tutorials on this site:

http://flashscript.biz/php.html

Brayshakes
05-23-2005, 11:05 PM
And that should work? The movie clip I used also contains am input form so should the text, "Sucess" just print to the input form?

cancerinform
05-23-2005, 11:16 PM
You better check one of those tutorials like for the poll or other php tutorials to look at the structure. "Success" is the name of a frame. If the the var result comes back from the server and is "Okay" then the timeline will jump to Success.