Connecting Tech Pros Worldwide Forums | Help | Site Map

Flash send value to database with PHP

Newbie
 
Join Date: May 2007
Posts: 11
#1: Jun 4 '07
Hi!

I know a solution for this problem and that is using this code:

PHP: (submitScore.php)
<CODE>
<?php
$nick = $_POST['Nick'];
$score = $_POST['Score'];
$kills = $_POST['Kills'];
$floor = $_POST['FloorNr'];

$db=mysql_connect("")
or die("Couldn't connect.");
mysql_select_db("databasename", $db);

mysql_query("INSERT INTO Table (Nickname,Score,Kills,Floor) VALUES ('$nick','$score','$kills','$floor')",$db);

mysql_close($db);
echo "Your score has been submited! ";
?>
</CODE>

Actionscript:
<CODE>
myData = new LoadVars();
myData.Nick = nickname.text;
myData.Score = _global.score;
myData.Kills = _global.TotalKills;
myData.FloorNr = _global.floorNr;

myData.send("submitScore.php", myData, "POST");
</CODE>

The problem with this is that submitScore.php pops up in the browser so that
the player can just refresh the submitScore.php page and in such a way
repeat the insert query to the database, adding the score several times.
Either I can make the page close down on its own or is there a way to insert a
value to a database without making the submitScore.php pup up and accessible
to the user?

kestrel's Avatar
Moderator
 
Join Date: Jul 2006
Location: California!!!
Posts: 898
#2: Jun 4 '07

re: Flash send value to database with PHP


You can go ahead and post this into the php forum as well, you might be able to find an answer there.
Reply