Flash Login with PHP and Mysql

How to connect flash to PHP

Page 1 of 1

1 Replies - 2099 Views - Last Post: 11 September 2009 - 05:49 AM

#1 miracleflex  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-September 09

Flash Login with PHP and Mysql

Post icon  Posted 03 September 2009 - 02:19 PM

Hi there! I am having some difficulties in connecting Flash to my php to check for usernames and password validity. I am using Actionscript 2.0. below are my codes for PHP an Flash:


PHP CODE (Mymembers.php)

<?php

$username = $_POST['uname'];
$password = $_POST['passw'];

$host = 'localhost';
$dbuser = '*****';
$dbpass = '*****';
$dbname = '*****';
$table = 'Mymembers';

$db = @mysql_connect($host, $dbuser, $dbpass) or die ("error = could not connect to $host");
$db = mysql_select_db($dbname);
if(!$db)
{
echo "&error = could not connect to $dbname table";
exit;
}


$query = mysql_query ("SELECT * FROM $table WHERE USERname = '$username' AND USERpass = '$password'");
$num = mysql_num_rows($query);
if($num>0)
{
echo "&user = ok";
}else{
echo "&error = not ok";
}

?>

Flash Code(AS2)

stop();

var submit:Button = Button(submit);
var uname:TextField = TextField(uname);
var passw:TextField = TextField(passw);
var msgbox:TextField = TextField(msg);

submit.onRelease = function() {
//call php to verify the correct username and password
var myVars:LoadVars = new LoadVars();
myVars.uname = uname.text;
myVars.passw = passw.text;
myVar.msgbox = msgbox.text;
myVars.onload = function(success) {
if (myVar.user == "Success") {
gotoAndStop("LoginSuccess");
} else {
gotoAndStop("LoginFailed");
}
};
myVars.sendAndLoad("http://www.location.com/Mymembers", myVars, "POST");
};





Please I really want to know what's goin on.Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Flash Login with PHP and Mysql

#2 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Re: Flash Login with PHP and Mysql

Posted 11 September 2009 - 05:49 AM

Hello,

Quote

if (myVar.user == "Success")


what about
if (myVar.user == "ok")


your php assigns "ok"/"not ok" when login succeeded/failed to the user var.
also, remove that space between = and ok
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1