Hello Everyone, I am working on a touch screen POS login interface that takes in a four digit user pin and searches a database. It uses Flash, PHP and MYSQL. I need PHP to return the user name and access level. The AS3 code below is what I have so far, but it doesn't work correctly.
"IntLogin" is the 4 digit pin that is sent to PHP when the user touches login on the GUI.
function onLoginClick(e:MouseEvent):void
{
keyLogin.gotoAndStop("KeyDn");
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("Login.php");
var variables:URLVariables = new URLVariables();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.method = URLRequestMethod.POST;
variables.login = intLogin;
request.data = variables;
trace(request.data = variables);
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);
function onComplete(event:Event):void{
var loader:URLLoader = URLLoader(event.target);
var variables:URLVariables = new URLVariables(loader.data);
txtUser.text = variables.username;
Next is the PHP code which works great in the browser when I implictly give $select a value, returning "username=Walker&access=1"
However, when I run the program from Flash it returns an undefined variable and the end of the PHP file.
<?php # Login.php
require_once ('mysqli_connect.php');
//Connect to the db
if (!empty($_POST['login'])){
$select = $_POST['login'];
$sql = "SELECT Last_Name AS name, Access_Level AS level FROM Users WHERE User_ID = '$select'";
$q = mysqli_query($dbc, $sql);
if($q){
$row = mysqli_fetch_array($q, MYSQLI_ASSOC);
$name = $row['name'];
$access = $row['level'];
echo "username=$name";
echo "&access=access";
}
}
?>
I have have tried debugging the both the PHP and the AS code, but I am stuck. When I trace in AS3 I get the following:
1445
login=1445
undefined
$access";
}
}
?>
Please if you anyone can help with this it would be greatly appreciated. I am on a strict timeline and I don't know what to do here.
Thanks:)
Jusmark
North America
Europe, Middle East and Africa
Asia Pacific