Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting & Posting username from Flash to PHP..?

Status
Not open for further replies.

triquad

Programmer
Feb 5, 2009
16
0
0
EG
I have a flash game that asks the user to enter his username & password then he can start playing the game. After that the score gets saved to MySQL next to his username & password. The final step is to display his scores in the flash game.

Everything works fine except for the last step which is calling back the scores from MySQL to the flash game.

I call the scores from MySQL using PHP file which sends the data to flash through XML. I can call the data from MySQL & display it in flash BUT I should enter a specific user name manually in the PHP file. The problem is that I can't make the flash game display the scores of the logged in user. for example: User A signs-in, plays the game, his/her score gets saved & then the problem occurs calling back his/her scores to the flash. In order to display User A scores in the Flash , I should replace the $username variable in the PHP file with "User A" so the scores can be displayed in the Flash file.

Below are the files I use to call the data from MySQL to Flash:
1. PHP file

Code:
<?php
session_start(); 

$link = mysql_connect("localhost","root","");
mysql_select_db("MY_DATABASE_NAME");
	$Username = $_POST['Username'];
$query = "SELECT score FROM TABLE_NAME WHERE Username = '$Username'";

$results = mysql_query ($query);

 "<?xml version=\"1.0\"?>\n";
echo "<TABLE_NAME>\n";

while($line = mysql_fetch_assoc ($results)) {

	echo "<item>" . $line["score"] . "</item>\n";
	
	}
	
	echo "</TABLE_NAME>\n"
	
	?>



2. AS2

Code:
var theXML:XML = new XML();
theXML.ignoreWhite = true;

theXML.onLoad = function() {
	var nodes = this.firstChild.childNodes;
	for(i=0;i<nodes.length;i++){
		theList.addItem(nodes[i].firstChild.nodeValue,i);
		ggu.text = (nodes[i].firstChild.nodeValue,nodes[i].firstChild.nodeValue);			
			}
	
}
theXML.load("[URL unfurl="true"]http://localhost/SOME_DIRECTORY/PHP[/URL] FILE NAME.php", 0, "POST");


CONCLUSION:
1. When I replace $Username in the PHP file with any username in the MySQL database (for example.. UserA). UserA scores gets displayed in flash. That's why I think the problem is that the PHP file does not get the logged in username from the flash file. I have been trying to solve this problem during the last 2 days but it seems like I can't figure out how to fix it. Any ideas ?! Your reply is much appreciated. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top