Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

Flash not sending variables to PHP

I have writtin a php script for a flash user login program however when I try to send the username and password vars to my php page, the script echo's "1" which means that the username and/or password are not in the database. I have put in the correct username and password but it will not work for some reason.
The other thing I need to figure out how to do, is have my php page send the number that has been echoed back to my flash document.
For example, if I was banned from the program, php would echo "2", then that number is read by flash and the appropriate action is taken.
Here is my actionscript:

loginBTN.onRelease = function() {
      status = "Loading...please wait..."
      myUser = new LoadVars()
      myUser.username = _root.username.text
      myUser.pwd = _root.pwd.text
      loadVariablesNum("http://www.website.com/scripts/login.php", myUser, "GET")
      myUser.onLoad = function() {
            if (myUser.status == 0) {
                                                gotoAndStop(10)
            }
            if (myUser.status == 1) {
                                                status = "Incorrect uesrname or password"
            }
            if (myUser.status == 2) {
                  status = "BANNED!"
            }
            if (myUser.status == 3) {
                  status = "Double login."
            } else {
                  status = "Error"
            }
      }
}

Here is my php page:

<?php      
      require_once "db_class.inc.php";
      require ('db.php');
      $connect = mysql_connect($dbhost, $dblogin, $dbpass) or die(mysql_error());
      $db_select = mysql_select_db($dbname) or die(mysql_error());
            $ipq = "SELECT ip FROM ip_ban";
            $ipr = mysql_query($ipq) or die(mysql_error());
                  while($iprow = mysql_fetch_assoc($ipr)) {
                        if($iprow["IP"] == $_ENV["REMOTE_ADDR"]) {
                            echo "&result=2&";
                              exit();
                        }
                  }
            $username = $HTTP_GET_VARS['username'];
            $pwd = $HTTP_GET_VARS['pwd'];
            $query = mysql_query("SELECT * FROM users WHERE username= \"$username\" AND password= \"$pwd\" ");
            if (mysql_num_rows($query) > 0) {
                  echo "&result=0&";
            }  else {
                  echo "&result=1&";
            }
?>


Any help would be great.

Cheers

-OBCT
0
OBCT
Asked:
OBCT
  • 3
1 Solution
 
DILORENZOCommented:
Hello, I think you could try

sendandload("http://www.website.com/scripts/login.php", myUser, "POST")

rather than

loadVariablesNum("http://www.website.com/scripts/login.php", myUser, "GET")

..this is where your passing to the php right. If not I don't see where you are.    Try not to use get with sensitive info or it will be visible.
0
 
OBCTAuthor Commented:
I tried your suggestion and changed my php to use HTTP_POST_VARS but it still didn't work.
0
 
OBCTAuthor Commented:
Ok, I managed to get my php script working but I had to use $HTTP_GET_VARS.
I tried returning the php result using trace, but it echo's 1 even if my username and password are correct.
Here is my code

stop()
Selection.setFocus(username)
loginBTN.onRelease = function() {
      this._parent.status = "1st stage complete"
      this._parent.myUser = new LoadVars()
      this._parent.myUser.username = _root.username.text
      this._parent.myUser.password = _root.password.text
      this._parent.myUser.onLoad = function() {
            
            trace(this.result);
            if (this.result == "0") {
           gotoAndStop(10)
            }
            else if (this.result == "1") {
           this._parent.status = "Incorrect uesrname or password"
            }
            else if (this.result == "2") {
                  status = "some value"
            }
            else if (this.result == "3") {
                  status = "ip ban"
            }
      };
      this._parent.myUser.sendAndLoad("http://www.dsfsadfsdfasd.com/scripts/login.php", this._parent.myUser, "GET")
}
0
 
OBCTAuthor Commented:
Never mind, I got it working :)
Thanks for your help anyway.

Cheers


-OBCT
0
 
LunchyCommented:
PAQed, with points refunded (500)

Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now