0 Replies Latest reply on Mar 1, 2010 7:47 AM by venkatsyss

    Regarding Http Service and Login

    venkatsyss Level 1

      hi,

       

      My question is ,without  submit the request ,the request is passed , the data  is sent back from the server it display the wrong result. If i have run the application the alert box is displayed  "test" . and display the pane1 it shows the successfully login.

       

      Please find me the solution to solve the problem.

       

      The Following Code Shows:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="lRequest.send()">
      <mx:HTTPService id="lRequest"   method="POST" useProxy="false" url="login.php" result="Display(event)">
      <mx:request xmlns="">
      <memname>{uname.text}</memname>
      <mempass>{upass.text}</mempass>
      </mx:request>
      </mx:HTTPService>  

       


      <mx:Panel title="My Login Application" paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10" width="300" height="200" >

       

      <mx:HBox>
          <mx:Label text="Username">
             
          </mx:Label>
          <mx:TextInput id="uname">
             
          </mx:TextInput>
         
      </mx:HBox>
      <mx:HBox>
          <mx:Label text="Password">
             
          </mx:Label>
          <mx:TextInput displayAsPassword="true" id="upass">
             
          </mx:TextInput>
      </mx:HBox>
          <mx:HBox>
              <mx:Button label="Submit" click="userCheck()">
                 
              </mx:Button>
              <mx:Button label="Cancel">
                 
              </mx:Button>
          </mx:HBox>
         
      </mx:Panel>

       

      <mx:Panel id="panel1" visible="false" includeInLayout="false" paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10">
      <mx:HBox>
          <mx:Label text="Successfully Login">
             
          </mx:Label>
      </mx:HBox>
         
      </mx:Panel>

       

      <mx:Panel id="panel2" visible="false" includeInLayout="false" paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10">
      <mx:HBox>
          <mx:Label text="Invalid Login">
             
          </mx:Label>
      </mx:HBox>
         
      </mx:Panel>

       

      <mx:Script>
          <![CDATA[
              import mx.rpc.events.ResultEvent;
              import mx.controls.Alert;
              private function userCheck():void{
                  lRequest.send();
              }
              private function Display(event:ResultEvent):void{
                  Alert.show("test");
                  if(String(event.result=="1")){
                      panel1.visible=true;
                      panel1.includeInLayout=true;
                  }else{
                      panel2.visible=true;
                      panel2.includeInLayout=true;
                  }
              }
          ]]>
      </mx:Script>

       


      </mx:Application>

       

      My PHP is:

       

      <?php
      $con=mysql_connect("localhost","root","");
      if(!$con){
          echo "Error in Connecting Database";
      }
      mysql_select_db("project",$con);

       

      if($_POST['memname']!=''){
      $query="select * from tbl_member where member_fname='".$_POST['memname']."' and member_lname ='".$_POST['mempass']."'";
          $ans=mysql_query($query);
          $rows=mysql_num_rows($ans);
          if($rows==1){
              echo "1";
          }
          else{
              echo "2";
          }
      }
      ?>

       

      Please find me the solution to solve the problem.

       

      Thanks and Regards,

      venkat.R