3 Replies Latest reply on Feb 28, 2010 5:26 PM by FuZZyLoGic0XFF

    I am new on flex, and i would like to create a simple login + password using amfphp

    skyracexx

      Hi all,

       

      I try to make a simple login password using mysql and amfphp, i have a little quesiton, i dont' know how to get back my response from php. Thanks in advance if anyone could help me.

       

      Best regards

       

      i would like to tell to the label    <mx:Label x="380" y="10" id="lResponse"/> the response from php

      I juste want to take back response from php.

       

      Here is my mxml :

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
          <fx:Script>
              <![CDATA[
                  import mx.controls.dataGridClasses.DataGridColumn;
                  import flash.net.Responder;
                  import mx.events.DataGridEvent;
                  import org.corlan.VOAuthor;
                 
                  private function checkpassword():void {
                      var newauthor:VOAuthor=new VOAuthor();
                      newauthor.lname_aut = nom.text;
                      newauthor.fname_aut = prenom.text;
                      myRemote.validate(newauthor);

       

                  }
                  private function checkInput():void
                  {
                      if(nom.text == "" || prenom.text == "")
                      {
                          lResponse.text = "Veuillez completer tout les champs";
                      }
                      else
                      {
                          lResponse.text = "connecter";
                          checkpassword();
                      //    checkLogin("login.Verify.validate",[nom.text,prenom.text]);
                      }
                  }
              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
              <mx:RemoteObject id="myRemote" destination="MyService" source="MyService"
                               endpoint="http://localhost/amfphp/gateway.php" showBusyCursor="true"/>
              </fx:Declarations>
         
         
          <s:Panel x="334" y="168" width="245" height="135" title="Identifiez vous" textAlign="center">
              <s:TextInput x="102" y="10" textAlign="left" id="nom" />
              <s:TextInput x="102" y="40" textAlign="left" id="prenom" />
              <s:RichText x="50" y="6" text="Login :" height="22" width="56" textAlign="left" verticalAlign="bottom"/>
              <s:RichText x="27" y="46" text="Password :" height="20"/>
              <s:Button x="125" y="70" label="Connecter" width="105" click="checkInput()"/>
              <mx:Label x="380" y="10" id="lResponse"/>
          </s:Panel>
      </s:Application>

       

      Here is my php code :

       

      <?php
      session_start();

       

      require_once ('./vo/org/corlan/VOAuthor.php');

       

      //conection info
      define( "DATABASE_SERVER", "127.0.0.1");
      define( "DATABASE_USERNAME", "root");
      define( "DATABASE_PASSWORD", "xxxx");
      define( "DATABASE_NAME", "flex360");

       

      class MyService {

       

       

       

          function validate($author){

              $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
              mysql_select_db(DATABASE_NAME);

              $user = $author[0];
              $pass = $author[1];

              $query = "SELECT DISTINCT * FROM authors_aut WHERE fname_aut = '$user' AND lname_aut = '$pass'";
              $rs = mysql_query($query);

              $var = mysql_fetch_assoc($rs);
              $u = $var["fname_aut"];
              $p = $var["lname_aut"];

              if ($pass != $p){
                  $response[0] = "INVALID";
                  $response[1] = "Invalid username and/or password";
              } else {
                  $response[0] = "VALID";
                  $response[1] = "Welcome $u";
              }
              return $response;
          }

       

      }

       

      ?>