;

PDA

Click to See Complete Forum and Search --> : AS3 URLLoader not getting vars from PHP


tokth
03-12-2009, 07:20 PM
I am having an issue in getting flash to call my PHP script and then get the variables back into flash once the PHP script has queried a mysql database. I have tried to chop things in the php script down to their bare essentials. I am new to AS3 so I am having some trouble integrating the two. I know that my DB info and querying works so it must be something with passing data between flash and PHP.

As for the PHP, I was trying to basically just get the data from the mysql database and then just send the proper string back to flash. This does not occur, and I believe it is becuase flash is not sending the data put into the input text boxes, by the user, to the php script when its called.


AS3

import caurina.transitions.*;
import fl.controls.DataGrid;
import fl.controls.ScrollPolicy;
import flash.events.*;
import flash.net.*;

var pass:String="";
var user:String="";
var vars:String="";
//trace(user);
//trace(pass);
var goalviewataGrid = new DataGrid();

function mainRequest(e:MouseEvent) {
// Prepare request

var request:URLRequest = new URLRequest("http://goaltracker.us/BrianPage/app/flashapp/scripts/authenticate.php");
request.method = URLRequestMethod.GET;

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);

function completeHandler(evt:Event) {

user = evt.target.data.user;
pass = evt.target.data.pass;
// vars = evt.target.data.vars;
// trace('auth is ' + vars);
trace('username is ' + user);

trace('password is ' + pass);
// if (vars== "TRUE") {

//load a custom function
firsthomeview();
// }
}

}




PHP

<?php

$user = $_GET['user'];
$pass = $_GET['pass'];

$dbuser="*********";
$dbpass="*********";
$dbname="*********";
$dbhostname="*********";

mysql_connect($dbhostname, $dbuser, $dbpass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbname) or die(mysql_error());



// does user exist?


$query = "SELECT username,password FROM user_tbl WHERE username='$user'";
$check_database = mysql_query($query);
$row = mysql_fetch_assoc($check_database);

if ($row != NULL){
extract($row);

$user = $row["username"];
$pass = $row["password"];

}

echo "user=$user";
echo "pass=$pass";

?>