1 Reply Latest reply on Jul 15, 2008 2:01 PM by ntsiii

    login using flex

    nitsmooth
      I m creating my login page in loginpage.mxml but the values are not getting sent to the php page login.php....plz help

      loginpage.mxml
      ---------------------------
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute">
      <mx:HTTPService id="Login" url=" http://localhost/mixbook/login.php" useProxy="false" method="POST">
      <mx:request xmlns="">
      <emailaddress>{emailaddress.text}</emailaddress>
      <password>{password.text}</password>
      </mx:request>
      </mx:HTTPService>

      <mx:Panel width="100%" height="100%" layout="absolute" y="5" x="19">

      <mx:Canvas label="View 1" width="100%" height="100%">
      <mx:Canvas label="or" width="100%" height="649" x="9" y="0" color="#0A3F4A" alpha="1.0">
      <mx:Button x="339.5" y="37" label="Home" width="72" click="navigateToURL(new URLRequest('home.swf'),'_top')"/>
      <mx:Button x="419.5" y="37" label="Create" click="navigateToURL(new URLRequest('create.swf'),'_top')"/>
      <mx:Button x="491.5" y="37" label="Explore" click="navigateToURL(new URLRequest('explore.swf'),'_top')"/>
      <mx:Panel x="10" y="67" width="863" height="40" layout="absolute" borderColor="#18237B"></mx:Panel>
      <mx:Label x="634" y="10" text="inbox"/>
      <mx:Label x="678" y="10" text="accounts"/>
      <mx:Label x="739" y="10" text="help"/>
      <mx:Label x="780" y="10" text="logout"/>
      <mx:ProgressBar id="progressBar" indeterminate="true" visible="false" />
      <mx:Text x="54" y="124" text="Login to Mixbook.com" fontSize="23" fontStyle="normal" textDecoration="underline"/>
      <mx:Text x="491.5" y="140" text="or" width="15.5" color="black" fontSize="11"/>
      <mx:Text x="530" y="137" text="sign up for an accounts" color="#0C7086" textDecoration="underline" fontSize="14" click="navigateToURL(new URLRequest('signup.swf'))"/>
      <mx:Panel x="22" y="166" width="758" height="351" layout="absolute" borderColor="#0B0000">
      <mx:Text x="78" y="10" text="Email Address:" fontSize="15" fontWeight="bold"/>
      <mx:Text x="78" y="71" text="Password:" fontSize="15" fontWeight="bold"/>
      <mx:TextInput x="301" y="13" borderStyle="solid" width="326" height="30" id="emailaddress"/>
      <mx:TextInput x="301" y="75" width="326" height="32" borderStyle="solid" id="password"/>
      <mx:CheckBox x="226" y="144" label="remember me on this computer" width="379" fontSize="12" fontWeight="bold"/>
      <mx:Button x="273" y="195" label="Login to Mixbook" cornerRadius="9" width="219" fontWeight="bold" fontSize="13" fillAlphas="[1.0, 1.0]" fillColors="[#A05F60, #0B4867]" color="#C49483"/>
      <mx:Text x="243" y="247" text="forgor your password"/>
      <mx:Text x="430" y="247" text="reset it" fontWeight="bold" fontSize="11" textDecoration="underline" click="Login.send()"/>
      </mx:Panel>
      <mx:TextArea x="79" y="10" text="reserved for logo" fontSize="19" width="209"/>

      </mx:Canvas>
      </mx:Canvas>

      </mx:Panel>
      </mx:Application>

      login.php
      -----------------
      <?php
      $con = mysql_connect(localhost, "root", "");
      if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
      mysql_select_db("mixbook" ,$con);
      $fp = fopen("test.txt","a+");
      fwrite($fp,$_POST[emailaddress]."\r\n");

      $email = $_POST[emailaddress];
      $pass = $_POST[password];

      $query = "select * from `usertable` where `emailaddress` = '".$_POST[emailaddress]."' and `password` = '".$_POST[password]."' ";
      //$query = "Select * from usertable where emailaddress = '".$_POST['emailaddress']."' and password = '".$_POST['password']."' ";
      $result = mysql_query($query);
      echo $query;
      $rowcount = mysql_num_rows($result);
      if($rowcount == 1)
      echo"login successfull";
      else
      echo"no";

      ?>
        • 1. Re: login using flex
          ntsiii Level 3
          Rather than building the request object declaritively and binding to the values you want to send, build it in AS so that you can debug to make sure your values are getting sent.

          private function tryLogin():void {
          var sEmail:String = emailaddress.text;
          var sPwd:String = password.text;
          trace("Email=" + sEmail + " Pwd=" + sPwd); //to be sure you have your values
          var oRequest:Object = {emailaddress:sEmail, password:sPwd};
          Login.send(oRequest);

          You will probably need a result handler to handle the login result.

          Tracy