Flash not sending variables to PHP

Posted on 2003-12-07
Last Modified: 2010-04-03
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("", myUser, "GET")
      myUser.onLoad = function() {
            if (myUser.status == 0) {
            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:

      require_once "";
      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&";
            $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.


Question by:OBCT
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 9905078
Hello, I think you could try

sendandload("", myUser, "POST")

rather than

loadVariablesNum("", 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.

Author Comment

ID: 9918189
I tried your suggestion and changed my php to use HTTP_POST_VARS but it still didn't work.

Author Comment

ID: 9919492
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

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() {
            if (this.result == "0") {
            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("", this._parent.myUser, "GET")

Author Comment

ID: 9919831
Never mind, I got it working :)
Thanks for your help anyway.



Accepted Solution

Lunchy earned 0 total points
ID: 9937978
PAQed, with points refunded (500)

Friendly Neighbourhood Community Support Admin

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flash doesn't load in Iphone and Ipad 22 503
Action Script commands 3 224
Action Script coding 1 192
Youtube video error 30 871
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question