# Help with writing a submit score action script \[F8\]

**URL:** <https://forum.kirupa.com/t/help-with-writing-a-submit-score-action-script-f8/258124>\
**Category:** flash\
**Created:** [April 21, 2008, 8:31am UTC](https://forum.kirupa.com/t/help-with-writing-a-submit-score-action-script-f8/258124 "2008-04-21T08:31:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ish100](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@ish100](https://forum.kirupa.com/u/ish100)\
**Post date:** [April 21, 2008, 8:31am UTC](https://forum.kirupa.com/t/help-with-writing-a-submit-score-action-script-f8/258124/1 "2008-04-21T08:31:15Z")

</div>

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]
