Solved

Flash not sending variables to PHP

Posted on 2003-12-07
6
271 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now