Solved

Flash not sending variables to PHP

Posted on 2003-12-07
6
279 Views
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("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
Comment
Question by:OBCT
  • 3
6 Comments
 

Expert Comment

by:DILORENZO
ID: 9905078
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
 
LVL 9

Author Comment

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

Author Comment

by:OBCT
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

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
 
LVL 9

Author Comment

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

Cheers


-OBCT
0
 
LVL 2

Accepted Solution

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

Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
free flash maker 5 216
Windows 7, Adobe Flash Player and Internet Explorer 11 15 103
Flash content not working in IE 11 on Windows 8.1 3 172
flash professional 3 20
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

809 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