Skip to main content
April 22, 2008
Question

Php form mailer/Flash help

  • April 22, 2008
  • 14 replies
  • 779 views
I have a php form that I am using with my Flash file. It works great so far, but I would like to get confirmation from the php in the Flash file, that the info has really been sent. I think it is already sent up in the php, but I don't know how to handle it in my Flash file. The php file is attached. Do I use the echo? How would I do that? What I want, is in my Flash file to say sending, until I get then feedback from the php, and then say, sent successfully.

Thanks a lot for any help!
This topic has been closed for replies.

14 replies

kglad
Community Expert
Community Expert
April 22, 2008
use result_lv as your 2nd parameter in your sendAndLoad() method.
Inspiring
April 22, 2008
>> send_lv.sendAndLoad("php/sendContact.php",send_lv,"Post");

You defined a result_lv, but are not using it? You should not have send_lv,
send back to itself... change that above line to:

send_lv.sendAndLoad("php/sendContact.php",result_lv);

POST is the default, so no it's not required.


--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


April 22, 2008
Dave,
thanks a lot. I think this got me really close.

This is what I have so far.

var send_lv = new LoadVars();
//send_lv.onLoad = ShowStatus;
//send_lv.EmailType = "Quote";
send_lv.Name = tName;
send_lv.FromEmail = tEmail;
send_lv.Subject = tSubject;
send_lv.Comments = tMsg;
send_lv.status = "";
send_lv.sendAndLoad("php/sendContact.php",send_lv,"Post");
this.showAlertMsg("Sending...");

var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
this.tf_showAlertMsg.text = "Thank you for sending us an email";
} else {
this.tf_showAlertMsg.text = "Email did not go through";
}
};
};


It is sending but not getting the echo yet. Do I need the Post there?

Thanks so much for the help!

Inspiring
April 22, 2008
Yes, using echo is fine. Have a look at the LoadVars class - specifically
the sendAndLoad method of it.

Essentially, you'll do something like this to get your return:

var sv = new LoadVars();
var rv = new LoadVars();

rv.onLoad = function(success:Boolean){
trace(this['Status']);
}

sv.Name = nameTextField.text;
sv.FromEmail = emailTextField.text;
etc...
sv.sendAndLoad("url of your php script", rv);

the rv.onLoad method will then be invoked when the php script echo's back.
If you uncomment the echo in your script, where you send back the &Status -
you should see the text in the onLoad function.

--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/