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

April 23, 2008
p.s. you've uncommented, at least, one of your php echo statements, correct?

No, I just did that. Does it matter which one? I tried the second one and it did not change anything.

...
//if($debug)
// echo "mes1 $ToEmailType $ToEmail $Subject $Message From: $Name $FromEmail\n ";

//mail to Eric Tillinghast
mail("brian@agilitygraphics.com","website contact form - $Subject", $Message, "From: $Name <".$Email.">");

//mail acknowledgement to the user
//$AcknowledgementMessage = "Hello $Name.\n\n Thank you for your interest in my art. I have received your email and will respond as soon as possible.\n\nThank You, \nEric Tillinghast.\n\n\nwww.erictillinghast.info";
//mail($Name."<".$Email.">", "I have received your email", $AcknowledgementMessage, "From: Eric Tillinghast <info@erictillinghast.info>");

//echo "&Status=Your quote request has been sent.";
?>


Ad the trace like this?
result_lv.onLoad = function(success:Boolean) {
trace(this.tf_showAlertMsg);
if (success) {
this.tf_showAlertMsg.text = "Thank you for sending us an email";
} else {
this.tf_showAlertMsg.text = "Email did not go through";
}
};


Kind of confused on all this right now...
Thank you for the help!



kglad
Community Expert
Community Expert
April 23, 2008
put a trace(this.tf_showAlertMsg) function in your onLoad method to see if the onLoad method is being called and if your path/name to your textfield is correct.

p.s. you've uncommented, at least, one of your php echo statements, correct?
April 23, 2008
Yeah, I tried that.

var send_lv = new LoadVars();
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";
}
};

//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",result_lv,"Post");
this.showAlertMsg("Sending...");


But it never triggers the
this.tf_showAlertMsg.text = "Thank you for sending us an email";

The email gets sent, but it just does not report back.
kglad
Community Expert
Community Expert
April 23, 2008
then follow dave's advice and remove your instantiation of result_lv and its onLoad method from that function.
April 23, 2008
I guess that is where i am lost...

kglad
Community Expert
Community Expert
April 23, 2008
well, submitListener.click has to be called before your sendAndLoad executes and that isn't going to happen with your code no matter what else you're doing and not showing.

what's that submitListener.click supposed to do, anyway?
April 23, 2008
It is all inside an ifStatment that is inside a function, which gets called by the button that send the form. Here is the full thing.

function validateForm(tName:String, tEmail:String, tSubject:String, tMsg:String):Void {
trace("validateForm was called");
if (tName == "" || tName == undefined) {
trace("tName if");
this.showAlertMsg("Please enter your name");
} else if (tEmail == "" || tEmail == undefined || tEmail.indexOf("@") == -1 || tEmail.indexOf(".") == -1) {
trace("Invalid email address: "+tEmail+" infexOf1: "+tEmail.indexOf("@")+" indexOf2: "+tEmail.indexOf("."));
this.showAlertMsg("Invalid email address");
} else if (tSubject == "" || tSubject == undefined) {
trace("tSubject if");
this.showAlertMsg("Please enter a subject");
} else if (tMsg == "" || tMsg == undefined) {
trace("tComments if");
this.showAlertMsg("Please enter some comments");
} else {
trace("the else was called...");
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",result_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";
}
};
};
}
}
function showAlertMsg(msg:String):Void {
this.tf_showAlertMsg.text = "";
this.tf_showAlertMsg.text = msg;
}

this.send_btn.onRelease = function() {
validateForm(tf_Name,tf_Email,tf_Subject,tf_Comments);
};


I tried the new way Dave posted and it still does not get the echo from the form.

Thanks so much to both of you for the help!


kglad
Community Expert
Community Expert
April 23, 2008
maybe he has a button component that's supposed to call the submitListener.click() function. so, he should have his sendAndLoad() method in that function
Inspiring
April 23, 2008
It doesn't work probably because you are defining result_lv within a
listener, which really doesn't make any sense to do. The sendAndLoad is what
triggers the send to go... and result_lv is not defined there. As far as I
can see you want to remove the submitListener, it doesn't seem to be doing
anything anyway.

So, your code would be:

var send_lv = new LoadVars();
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";
}
};

//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",result_lv,"Post");
this.showAlertMsg("Sending...");



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


April 22, 2008
Mmmmhhh, I did that and now it is not working at all anymore.

I have this now.

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",result_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";
}
};
};