2 Replies Latest reply on Feb 4, 2009 4:53 PM by brettcristofer

    Beginner difficulty

    conorgriffin
      Hi, I'm stuck on what must be a basic problem.

      I send an HTTPService request to a php script on my server.

      The php script checks a database for the username and password supplied and returns either a true/false response in the following format

      [CODE]<loginState>true</loginState>[/CODE]
      OR
      [CODE]<loginState>false</loginState>[/CODE]

      Then my actionscript in my Flex page checks the returned value as follows:

      [CODE]
      ....
      <mx:Script>
      <![CDATA[
      import mx.messaging.messages.HTTPRequestMessage;
      import mx.rpc.events.ResultEvent;



      private function doLogin(e:MouseEvent):void
      {
      loginCall.url = " http://www.myurl.com/logon2.php";
      loginCall.send();
      }

      private function onResult(e:ResultEvent):void
      {
      if(e.result.loginState == "true")
      {
      currentState = "Logged In"
      }else{
      mx.controls.Alert.show("Response = " + e.result.loginState);
      }
      }
      ]]>
      </mx:Script>

      <mx:HTTPService id="loginCall" result="onResult(event)" method="POST" useProxy="false">
      <mx:request xmlns="">
      <userid>
      {userName.text}
      </userid>
      <password>
      {password.text}
      </password>
      </mx:request>
      </mx:HTTPService>
      ....
      [/CODE]


      Despite the server returning
      [CODE]<loginState>true</loginState>[/CODE]

      the script is popping up an alert window which says

      [CODE]Response = true[/CODE]

      if it's of any use I will post the full script but can anyone see the problem?


      Does the php script need to output any header info or are the <loginState> tags sufficient for the Flex app to parse the response?