2 Replies Latest reply on May 15, 2009 1:57 AM by leoserra

    Post from Flex, catch it in other domain and redirect

    leoserra

      Hi everybody,

       

      I'm new in Flex, altought I have some work already done in AS3.

       

      I've puzzled by a simple application that I was asked to do. I wanted to learn Flex, so yhis was an oportunity to start, but as always, when irt comes for a new applications, or programming skills, troubles appears from all spots.

       

      So the question that I have, I think is a simple one, but requires knowledge of ASP (because that's the script language used here), but if you know more about PHP, that's no problem.

       

      So here it is:

      I'm making a simple form that has to be distributed by other servers, that is, other webpages can put this form, provided that I give them the swf file. In this form user put the login and password. Other variables are established and have their value fixed. I want to be able to submit the data to another page that can process that information, and it redirects accordingly. Since this is in another domain, I think I have to use a "proxy" file to pass that information (unless you know another way to do this).

       

      The problem is that the form info is POSTed to this proxy, and I want to rePOST it to the validation page. But since this proxy will make a server to server communication, this doesn't work, the information is passed, but I can't make no redirection with POST and I don't want to use querystrings, since this will be kept inthe browser history.

       

      Does anyone have any ideia how to do it? Any example?... thoughts?

       

      Thanks

        • 1. Re: Post from Flex, catch it in other domain and redirect
          valhallaboy

          hi, try this

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#FFFFFF" width="1050" height="700" borderColor="#FCFDFD" backgroundGradientAlphas="[0.0, 0.0]">

           

          <mx:Script>

           

                  private function send_data():void {

           

                          var req_var:URLRequest = new URLRequest("http://localhost/testPost/testPost-debug/script/catch.php");
                          req_var.method = URLRequestMethod.POST;

           

                          var postData:URLVariables = new URLVariables();
                          postData.testField = testField.text;

           

                          req_var.data = postData;
                          navigateToURL(req_var,"_self");

           


                      }
          </mx:Script>

           

          <mx:TextInput height="25" width="100" fontFamily="Trebuchet MS" fontSize="11" id="testField" x="27" y="62"/>
          <mx:Button width="120" label="Send" fillAlphas="[1.0, 0.86, 1.0, 0.42]" fillColors="[#FDFBFB, #E9E3E3, #EBE6E6, #FDFBFB]" color="#050505" id="SendBTN" click="send_data()"  x="135" y="64"/>
          </mx:Application>

           

           




          //catch.php code
          <?php
               $testField = $_POST["testField"];
               echo $testField;
          ?>

          i hope this helpfull
          • 2. Re: Post from Flex, catch it in other domain and redirect
            leoserra Level 2

            Hi Valhallaboy,

             

            I manage to make a similar approach to what you say... since I'm new in Flex, I didn't know that you could send data with POST... and Flash can do it too, I'm always learning new stuff

             

            I'm not going to post my code, since is very similar to what you sent, the only difference is that the information is then sent, by the PHP, to another domain webpage.

             

            Thanks anyway