Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / May 2005



Tip: Looking for answers? Try searching our database.

loadVariables Command help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
_Toe_ - 18 May 2005 16:10 GMT
Hello,

I have a MYSQL database named "Users".  I am trying to grab the fields "User"
and "Password" for use in a login script. (of course)  I am unsure of the
syntax of the loadVariables command, and how to use it to grab the data from a
MYSQL database.

Thanks,
C
Randy1969 - 19 May 2005 17:31 GMT
If your going to load the information, then you would need the LoadVars object to call an ASP, PHP or some other server side processing page to talk to the database.
_Toe_ - 21 May 2005 16:24 GMT
Ok, So the script in PHP would need to find and grab "User" and "Password"
fields from the database.  What would the flash commanding look like?

LoadVariables "user" "password" from blah.php?  

Thanks,
C
Joaquim Lopes - 21 May 2005 21:21 GMT
On the Flash side use this:

var dataToSend:LoadVars = new LoadVars();
var answer:LoadVars = new LoadVars();

dataToSend.username = username.text;
dataToSend.sendAndLoad("http://localhost/login.php", answer, "POST");

answer.onLoad = function(success)
{
    if(success)
    {
                   if(this.numElements == 1)   // There can be only one user
with this name...
                  {
        if(this.userPasword == userPasword.text)
        {
            // everything is good...
        }
        else
        {
            // user entered the wrong password...
        }
                  }
    }
}

On the PHP side:

<?php
    $hostname = "localhost";
    $database = "whatever";
    $username = "username";
    $password = "top secret";
    $con = mysql_pconnect($hostname, $username, $password) or die(mysql_error());

    mysql_select_db($database, $con);

    $search = sprintf("select * from users where username = '%s'",
$_POST["username"]);
    $data = mysql_query($search, $con) or die(mysql_error());
    $line = mysql_fetch_assoc($data);
    $num_lines = mysql_num_rows($data);
    $result = "&numElements=" . $num_lines;
    if($num_lines != 0)
    {
        $result .= sprintf("&name=%s&password=%s",
                        utf8_encode($line['username']),
                        utf8_encode($line['password']));
    }
    echo $result;
    mysql_free_result($con);
?>

Hope this helps.
adireddy - 23 May 2005 09:32 GMT
Refer http://www.devarticles.com/c/a/Flash/The-Power-of-LoadVars-Object/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.