4 Replies Latest reply on Jan 4, 2011 12:41 PM by rehoover51

    POST data from Flash Builder Form

    GRY086

      Flash builder 4 makes it easy to call external php files.  I am really enjoying this feature.

       

      I am building an email form.

      There is a server-side PHP Script. I created an HTTP service to call the script.

      The script sends me a test-message upon service call.

       

      My problem is I don't know how to set  Post Values in Flash Builder.

      I Don`t know how to tell Flash Builder that the 2 fields (msg and email address) Must be sent along with the HTTP Request.

       

      In the PHP Script,  I am using

      $user= $_POST[' id of field in Flash Builder ' ];

      but $user is always empty.

       

      in Flash Builder, the email form has a button.

      On click, the button calls:

       

           protected function button_clickHandler(event:MouseEvent):void
           {
               Operation1Result5.token = sendMail.Operation1();
           }

       

      PS

      I first wrote this using the PHP service, but FLash Builder constantly failed to compile the service because my dev environment does not have smtp. Flash Builder would not even allow me to create the PHP class w/ send function.  Too bad, because using PHP classes, I would be able to pass along variables as method parameters.

        • 1. Re: POST data from Flash Builder Form
          SpaghettiCoder Level 3

          var _params:Object = new Object()

          _params.EmailAddress = ""; //BIND TO A VARIABLE, or BIND TO A FIELD

          _params.Message = ""; //BIND TO A VARIABLE, or BIND TO A FIELD

           

          var _httpServiceName:HTTPService = new HTTPService();

          _httpServiceName.url="../blah/blah/blah.php";

          _httpService.method="POST";

          _httpService.addEventListener(FaultEvent.FAULT, httpServiceFaultHandler);

          _httpService.addEventListener(ResultEvent.RESULT, httpServiceResultHandler);

          _httpService.send(_params)

           

          /*

          _params is what you want to send back to server

          _httpService.send(_params)

          */

           

          /* PHP */

          /*

          $_POST['EmailAddress']

          $_POST['Message']

          */

          • 2. Re: POST data from Flash Builder Form
            GRY086 Level 1

            Is this Compliant with Flash Builder 4 service architecture?

            this looks like the services I used to define in Flex 2.

            • 3. Re: POST data from Flash Builder Form
              SpaghettiCoder Level 3

              What does compliant with Flash Builder 4 Service Architecture mean? you got a link to what that entails...

              • 4. Re: POST data from Flash Builder Form
                rehoover51

                     <s:HTTPService id="studentService"
                           url="yourURL"
                          result="studentService_resultHandler(event)"
                          fault="studentService_faultHandler(event)" > 

                        <s:request>
                         <EMail>{email.text}</EMail>

                          <Message>{message.text}</Message>
                         </s:request>

                     </s:HTTPService>

                 

                this is how you create POST sends for your HTTP service (i am using code that has 2 bindable text boxes, but you can use variables or text.

                 

                good luck!

                reh