Jump to content

Recommended Posts

Okay ive been playing around with a flash game which i created.

The game is integrated into an arcade for a text-based game.

 

Okay basically im trying to get the end scores for the game and send them to a php script.

The php script is then meant to process the score and see if the player is worthy enough to be credited money in the actual text-based game.

 

Heres the code which is meant to send information to the php script:

_root.finalscore=_root.score;

var receiver_lv:LoadVars = new LoadVars();
receiver_lv.onLoad = function(ok){
      if(ok){
           message.text = receiver_lv.message;
	   score = _root.score;
	   getURL("flashtophp1.php", this, "POST");
      }else{
           message.text = "There was an error!!";
      }
}
receiver_lv.load("flashtophp1.php");

 

Okay and heres the php script which then processes it:

<?
$username= $_SESSION['username'];

$score= $_POST['score'];
//OKAY THE PROBLEM IS THAT THE SCRIPT READS THE POST VAR AS EMPTY
if ($score < "100"){
$msg="You need 100 to win a prize! your score was $score $username";
}else{
$money= $score*5;
$msg="You earned £$money ".ucfirst($username)."";
mysql_query("UPDATE users SET money=money+'$money' WHERE username='$username'");
}

echo "&message=$msg $score";
?>

Well the problem is that the $_POST['score'] var is empty.

Link to comment
https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/
Share on other sites

i don't know if this is what you really want, but couldn't u put the score in the url and then just get it using php.

 

flashtophp1.php?score=125

 

$score = $_GET['score'];

then carry on?

 

That method is always possible, but with the $_POST you have less of a security risk.

To get data into your Flash application you can you XML sockets. One of the first big things I made in Flash used Flash sockets to communicate to a C++ socket server. However you do it, I would recommend against using Javascript - just introduces too many browser support issues.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.