[flexcoders] Re: Problem with Flex form
I tried the link you sent and I get the same result - Two alert boxes telling me the message was emailed etc. The fault handler will be called if there is a fault on the service itself. eg. you set a timeout of 15 seconds on the service and the server does not respond for 15 seconds. In your situation you need to send back messages and then display a message depending on the message returned. eg. In PHP: $returnText = Success; if(!stripos($mail_to, @)) { $returnText = Malformed email address; } $OK = mail ($mail_to, $subject, $message, $headers); if (!$OK) { $returnText = Failed to send email; } echo $returnText; In Flex: private function resultHandler(event:ResultEvent):void { switch(event.result.toString()) { case Success: Alert.show(Thank you! Your message has been emailed, Thank you!); break; case Malformed email address: Alert.show(email address incorrect. It must contain an @); break; default: Alert.show(event.result.toString()); break; } } --- In flexcoders@yahoogroups.com, brucewhealton [EMAIL PROTECTED] wrote: Did you try the form itself? I guess I didn't show the link. It is here: http://futurewavedesigns.com/ContactUs/ContactForm.html When I enter information into the form, I get no response after I hit Submit. Can you try that page and see what happens for you? Unless you tried it already but I didn't list the page. I think it is fixed. It seems to work fine now. I just need to add some validation. I have this in my php form mailer: $OK = mail ($mail_to, $subject, $message, $headers); if ($OK) { echo 'sent=OK'; } else { echo 'sent=ERROR'; } I don't know how to make it not send the message and set an error. If that does happen, my Flex code checks for event.result=ERROR which I don't think is going to work with the php code I just listed. I hope someone here reading this knows some about php so that I can figure out what to do to change the code so that it gives the user a message if the email was not sent. I tried something that wasn't working which is this: else { die(failed); } That failed to cause any response at all from the form. Bruce --- In flexcoders@yahoogroups.com, valdhor stevedepp@ wrote: It works for me although it does display the alert twice - once for the eventListener you add in sendMyData and once for the result handler in the HTTPService tag. In your result handler you should be checking the response you get back from the server and display an alert accordingly. One thing that will probably help you out a lot is to get an HTTP debugging proxy like Charles (http://www.charlesproxy.com/). I use it every day. --- In flexcoders@yahoogroups.com, brucewhealton bruce@ wrote: Hello all, I have been unable to figure out why something simple is not happening in a form of mine. I have a form that does successfully take the user input and email it to us. However, for some reason, the Alert button that should give the user feedback is not working. It just hangs there when the user clicks on the submit button. I will need to share the code to get help with this. It is very basic and it does send the email message. I'll trim off extraneous appearance code that is not related to the actual logic of the form. So, we have the main application that has a Panel that calls the ContactFormComp (for ContactFormComponent)(leaving off the Application tag, of course: mx:Panel title=Contact Future Wave Designs forms:ContactFormComp id=MyContactForm/ /mx:Panel So, now we have the form component - this will be a bit longer, though still rather simple, but I don't know why it doesn't call the Alert function: ?xml version=1.0 encoding=utf-8? mx:Form xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private function sendMyData():void { var obj:Object = new Object(); obj.Name = Name.text; obj.email = email.text; obj.phone = phone.text; obj.message = message.text; myContactService.send(obj); myContactService.resultFormat = text; myContactService.addEventListener(ResultEvent.RESULT, resultHandler); myContactService.addEventListener(FaultEvent.FAULT, fault_handler); } private function resetForm(event:MouseEvent):void { Name.text = ; email.text = ; phone.text = ; message.text = ; } private function resultHandler(event:ResultEvent):void { Alert.show(Thank you! Your message has been emailed, Thank you!); } private function fault_handler():void { Alert.show(There was a problem., Problem Encountered); } ]] /mx:Script mx:HTTPService
Re: [flexcoders] Re: Problem with Flex form
Under HTTPService in LiveDocs: Due to a software limitation, HTTPService does not generate user-friendly error messages when using GET. Could that be your problem? On Tue, Nov 11, 2008 at 3:55 PM, brucewhealton [EMAIL PROTECTED]wrote: Did you try the form itself? I guess I didn't show the link. It is here: http://futurewavedesigns.com/ContactUs/ContactForm.html When I enter information into the form, I get no response after I hit Submit. Can you try that page and see what happens for you? Unless you tried it already but I didn't list the page. I think it is fixed. It seems to work fine now. I just need to add some validation. I have this in my php form mailer: $OK = mail ($mail_to, $subject, $message, $headers); if ($OK) { echo 'sent=OK'; } else { echo 'sent=ERROR'; } I don't know how to make it not send the message and set an error. If that does happen, my Flex code checks for event.result=ERROR which I don't think is going to work with the php code I just listed. I hope someone here reading this knows some about php so that I can figure out what to do to change the code so that it gives the user a message if the email was not sent. I tried something that wasn't working which is this: else { die(failed); } That failed to cause any response at all from the form. Bruce --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, valdhor [EMAIL PROTECTED] wrote: It works for me although it does display the alert twice - once for the eventListener you add in sendMyData and once for the result handler in the HTTPService tag. In your result handler you should be checking the response you get back from the server and display an alert accordingly. One thing that will probably help you out a lot is to get an HTTP debugging proxy like Charles (http://www.charlesproxy.com/). I use it every day. --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, brucewhealton bruce@ wrote: Hello all, I have been unable to figure out why something simple is not happening in a form of mine. I have a form that does successfully take the user input and email it to us. However, for some reason, the Alert button that should give the user feedback is not working. It just hangs there when the user clicks on the submit button. I will need to share the code to get help with this. It is very basic and it does send the email message. I'll trim off extraneous appearance code that is not related to the actual logic of the form. So, we have the main application that has a Panel that calls the ContactFormComp (for ContactFormComponent)(leaving off the Application tag, of course: mx:Panel title=Contact Future Wave Designs forms:ContactFormComp id=MyContactForm/ /mx:Panel So, now we have the form component - this will be a bit longer, though still rather simple, but I don't know why it doesn't call the Alert function: ?xml version=1.0 encoding=utf-8? mx:Form xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private function sendMyData():void { var obj:Object = new Object(); obj.Name = Name.text; obj.email = email.text; obj.phone = phone.text; obj.message = message.text; myContactService.send(obj); myContactService.resultFormat = text; myContactService.addEventListener(ResultEvent.RESULT, resultHandler); myContactService.addEventListener(FaultEvent.FAULT, fault_handler); } private function resetForm(event:MouseEvent):void { Name.text = ; email.text = ; phone.text = ; message.text = ; } private function resultHandler(event:ResultEvent):void { Alert.show(Thank you! Your message has been emailed, Thank you!); } private function fault_handler():void { Alert.show(There was a problem., Problem Encountered); } ]] /mx:Script mx:HTTPService id=myContactService url=mail_sender.php method=POST result=resultHandler(event) resultFormat=text/ mx:Label text=Your Contact Information/ mx:FormItem label=Name: mx:TextInput id=Name width=200 / /mx:FormItem mx:FormItem label=Email: mx:TextInput id=email width=200/ /mx:FormItem mx:FormItem label=Phone Number: mx:TextInput id=phone width=200/ /mx:FormItem mx:FormItem label=Message: mx:TextArea id=message width=200/ /mx:FormItem mx:FormItem mx:Button label=Submit fontSize=16 click=sendMyData()/ /mx:FormItem mx:FormItem mx:Button label=Reset Form fontSize=16 click=resetForm(event)/ /mx:FormItem /mx:Form I don't know if there is a problem with my php code but it does email the form. In order to share that, I have the php code in a text file here: http://futurewavedesigns.com/ContactUs/mail_sender.php.txt You'll see it is basic. Please let
[flexcoders] Re: Problem with Flex form
It works for me although it does display the alert twice - once for the eventListener you add in sendMyData and once for the result handler in the HTTPService tag. In your result handler you should be checking the response you get back from the server and display an alert accordingly. One thing that will probably help you out a lot is to get an HTTP debugging proxy like Charles (http://www.charlesproxy.com/). I use it every day. --- In flexcoders@yahoogroups.com, brucewhealton [EMAIL PROTECTED] wrote: Hello all, I have been unable to figure out why something simple is not happening in a form of mine. I have a form that does successfully take the user input and email it to us. However, for some reason, the Alert button that should give the user feedback is not working. It just hangs there when the user clicks on the submit button. I will need to share the code to get help with this. It is very basic and it does send the email message. I'll trim off extraneous appearance code that is not related to the actual logic of the form. So, we have the main application that has a Panel that calls the ContactFormComp (for ContactFormComponent)(leaving off the Application tag, of course: mx:Panel title=Contact Future Wave Designs forms:ContactFormComp id=MyContactForm/ /mx:Panel So, now we have the form component - this will be a bit longer, though still rather simple, but I don't know why it doesn't call the Alert function: ?xml version=1.0 encoding=utf-8? mx:Form xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private function sendMyData():void { var obj:Object = new Object(); obj.Name = Name.text; obj.email = email.text; obj.phone = phone.text; obj.message = message.text; myContactService.send(obj); myContactService.resultFormat = text; myContactService.addEventListener(ResultEvent.RESULT, resultHandler); myContactService.addEventListener(FaultEvent.FAULT, fault_handler); } private function resetForm(event:MouseEvent):void { Name.text = ; email.text = ; phone.text = ; message.text = ; } private function resultHandler(event:ResultEvent):void { Alert.show(Thank you! Your message has been emailed, Thank you!); } private function fault_handler():void { Alert.show(There was a problem., Problem Encountered); } ]] /mx:Script mx:HTTPService id=myContactService url=mail_sender.php method=POST result=resultHandler(event) resultFormat=text/ mx:Label text=Your Contact Information/ mx:FormItem label=Name: mx:TextInput id=Name width=200 / /mx:FormItem mx:FormItem label=Email: mx:TextInput id=email width=200/ /mx:FormItem mx:FormItem label=Phone Number: mx:TextInput id=phone width=200/ /mx:FormItem mx:FormItem label=Message: mx:TextArea id=message width=200/ /mx:FormItem mx:FormItem mx:Button label=Submit fontSize=16 click=sendMyData()/ /mx:FormItem mx:FormItem mx:Button label=Reset Form fontSize=16 click=resetForm(event)/ /mx:FormItem /mx:Form I don't know if there is a problem with my php code but it does email the form. In order to share that, I have the php code in a text file here: http://futurewavedesigns.com/ContactUs/mail_sender.php.txt You'll see it is basic. Please let me know if you see any error explaining why it doesn't get to the Alert message. thanks, and Here's an additional issue... If anyone knows php how would I send a message from the php form saying Ok or Fault. That is in the code but I am not sure how to send it back to Flex. Thanks Bruce
[flexcoders] Re: Problem with Flex form
Did you try the form itself? I guess I didn't show the link. It is here: http://futurewavedesigns.com/ContactUs/ContactForm.html When I enter information into the form, I get no response after I hit Submit. Can you try that page and see what happens for you? Unless you tried it already but I didn't list the page. I think it is fixed. It seems to work fine now. I just need to add some validation. I have this in my php form mailer: $OK = mail ($mail_to, $subject, $message, $headers); if ($OK) { echo 'sent=OK'; } else { echo 'sent=ERROR'; } I don't know how to make it not send the message and set an error. If that does happen, my Flex code checks for event.result=ERROR which I don't think is going to work with the php code I just listed. I hope someone here reading this knows some about php so that I can figure out what to do to change the code so that it gives the user a message if the email was not sent. I tried something that wasn't working which is this: else { die(failed); } That failed to cause any response at all from the form. Bruce --- In flexcoders@yahoogroups.com, valdhor [EMAIL PROTECTED] wrote: It works for me although it does display the alert twice - once for the eventListener you add in sendMyData and once for the result handler in the HTTPService tag. In your result handler you should be checking the response you get back from the server and display an alert accordingly. One thing that will probably help you out a lot is to get an HTTP debugging proxy like Charles (http://www.charlesproxy.com/). I use it every day. --- In flexcoders@yahoogroups.com, brucewhealton bruce@ wrote: Hello all, I have been unable to figure out why something simple is not happening in a form of mine. I have a form that does successfully take the user input and email it to us. However, for some reason, the Alert button that should give the user feedback is not working. It just hangs there when the user clicks on the submit button. I will need to share the code to get help with this. It is very basic and it does send the email message. I'll trim off extraneous appearance code that is not related to the actual logic of the form. So, we have the main application that has a Panel that calls the ContactFormComp (for ContactFormComponent)(leaving off the Application tag, of course: mx:Panel title=Contact Future Wave Designs forms:ContactFormComp id=MyContactForm/ /mx:Panel So, now we have the form component - this will be a bit longer, though still rather simple, but I don't know why it doesn't call the Alert function: ?xml version=1.0 encoding=utf-8? mx:Form xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private function sendMyData():void { var obj:Object = new Object(); obj.Name = Name.text; obj.email = email.text; obj.phone = phone.text; obj.message = message.text; myContactService.send(obj); myContactService.resultFormat = text; myContactService.addEventListener(ResultEvent.RESULT, resultHandler); myContactService.addEventListener(FaultEvent.FAULT, fault_handler); } private function resetForm(event:MouseEvent):void { Name.text = ; email.text = ; phone.text = ; message.text = ; } private function resultHandler(event:ResultEvent):void { Alert.show(Thank you! Your message has been emailed, Thank you!); } private function fault_handler():void { Alert.show(There was a problem., Problem Encountered); } ]] /mx:Script mx:HTTPService id=myContactService url=mail_sender.php method=POST result=resultHandler(event) resultFormat=text/ mx:Label text=Your Contact Information/ mx:FormItem label=Name: mx:TextInput id=Name width=200 / /mx:FormItem mx:FormItem label=Email: mx:TextInput id=email width=200/ /mx:FormItem mx:FormItem label=Phone Number: mx:TextInput id=phone width=200/ /mx:FormItem mx:FormItem label=Message: mx:TextArea id=message width=200/ /mx:FormItem mx:FormItem mx:Button label=Submit fontSize=16 click=sendMyData()/ /mx:FormItem mx:FormItem mx:Button label=Reset Form fontSize=16 click=resetForm(event)/ /mx:FormItem /mx:Form I don't know if there is a problem with my php code but it does email the form. In order to share that, I have the php code in a text file here: