Hi guys,
I have basicly made a high score table and need some help writing an action script that submits the users score.
A friend of mine gave me a the action script and the PHP code but being a newbie im just not sure where do I put my variables.
Befor you guys look at the script just let you know that my database table names are:
-name (for the users name when they submit their score)
-number_of_attempts
-number_of_wrong_attempts
The input text box for the user to submit their name is called “playername”.
The dynamic text box that displays all the users attempts is called “correct_total”
The dynamic text box that displays all the users WRONG attempts is called “wrong_total”
The variables are ment to be sent to:
playername ====> name
correct_total ====> number_of_attempts
wrong_total ====> number_of_wrong_attempts
Flash code:
[COLOR=#000000][COLOR=#007700]function [/COLOR][COLOR=#0000bb]insertVars[/COLOR]COLOR=#007700{
[/COLOR][COLOR=#0000bb]sv [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000bb]LoadVars[/COLOR]COLOR=#007700;
[/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]name [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]name[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]text[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]number_of_attempts [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]number_of_attempts[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]text[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]number_of_wrong_attempts [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]number_of_wrong_attempts[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]text[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]sendAndLoad[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]‘insertValues.php’[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]‘POST’[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]onLoad [/COLOR][COLOR=#007700]= function(){
if([/COLOR][COLOR=#0000bb]sv[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]ret [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#dd0000]“Record Updated”[/COLOR][COLOR=#007700]){
[/COLOR][COLOR=#ff8000]// run a function to reload the database values into Flash
[/COLOR][COLOR=#007700]}
};
};
[FONT=Arial][COLOR=Black]PHP code:[/COLOR][/FONT]
[/COLOR][/COLOR][COLOR=#000000][COLOR=#0000bb]$name [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]name[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]$number_of_attempts [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]number_of_attempts[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]$number_of_wrong_attempts [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000bb]number_of_wrong_attempts[/COLOR][COLOR=#007700]];
[/COLOR][COLOR=#0000bb]mysql_connect[/COLOR]COLOR=#007700;
@[/COLOR][COLOR=#0000bb]mysql_select_db[/COLOR]COLOR=#007700 or die( [/COLOR][COLOR=#dd0000]“Unable to select database”[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000bb]$query [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]“INSERT INTO yourtable VALUES (’$name’,’$number_of_attempts’,’$number_of_wrong_attempts’)”[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]mysql_query[/COLOR]COLOR=#007700;
echo [/COLOR][COLOR=#dd0000]"&ret=Record Updated&"[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]mysql_close[/COLOR]COLOR=#007700;[/COLOR][/COLOR]