0 Replies Latest reply on Mar 28, 2009 11:16 AM by chinchiheather

    using actionscript with php and sql to create login

      i'm trying to create a login page in a flash file using AS2. I want to check if the username and password that the user has typed in match those stored in a mysql database, using php, and if they're correct let them continue to the next frame.

      the code on the first frame of my flash file is:


      var lvSend:LoadVars = new LoadVars();
      var lvReceive:LoadVars = new LoadVars();

      btnLogin.onRelease = function ()

      lvSend.username = userText.text;
      lvSend.pass = passText.text;
      lvSend.sendAndLoad(" http://localhost/widget/index.php", lvReceive, 'POST');

      lvReceive.onLoad = function(success:Boolean) {
      if (success) {
      if (this.login == "success") {
      trace("login succeeded");
      trace("login failed");
      } else {
      trace("no reponse from server");


      and on my PHP file is:


      $user = $_POST['username'];
      $pass = $_POST['pass'];

      $database = new mysqli('localhost', 'root', '', 'widget');
      $query = $database->query("SELECT * FROM users WHERE username = '$user' && password = '$pass'");

      $num = $query->num_rows;

      if($num == 1)
      echo "login=success";

      echo "login=failed";


      Whenever I try and log in with any of the details stored in the sql database login failed is traced back.
      Can anyone see where I've gone wrong? I'd really appreciate any help.