Saving data to file (HiScore table)


New member
Tutorial Author
Feb 19, 2018
Hello everyone!

This question was answered in the Monkey-X forum, I checked the archive, but the answer wasn't in the archive. This may be helpful to many people.

How to implement hiscore system in HTML5 target without the native filesystem.

My best guess is to use POST and GET methods and use PHP.

I would like to have implementation where the hiscores are printed into webpage, not inside the game itself. Should be simple, but I know hardly anything about PHP.


Active member
3rd Party Module Dev
3rd Party Tool Dev
Mar 5, 2018
This is my solution in general. basicaly you need 3 task.
1. First task is to send the score to the php using httprequest
- use http:/ as address. This is how you send input to php file.
- in php you do:
This is how you get the value send by your app.​
- You app send this score data only when user make a big score progress​
2. Process the value into SQL database
-You connect with database using mysqli_connect("localhost",$user,$password,$name);
-You put this data $NAME, $SCORE and TIMESTAMP into database
-You let the TIMESTAMP auto. Means it will auto put current server time when the score is send.
-You use command $quary = "INSERT INTO yourUserData (NAME,SCORE) VALUE({$NAME},'{$SCORE}')";
-This php just put data in SQL, data will be filter and delete during display below​
3. To display all users score in website
-Create another php to display result.
-Read the SQL data by assending order of the score.
$quary = "SELECT * FROM yourUserData ORDER BY SCORE ASC";​
-You can limit the amount to display by look at TIMESTAMP or minimum SCORE
-You can also delete SQL data which it TIMESTAMP or minimum SCORE not meet the minimum. For example score too low or data has been long time ago.
-You delete using $quary = "DELETE FROM yourUserData WHERE SCORE>= 40000";​

Hope this can help.


New member
Tutorial Author
Feb 19, 2018
Very good answer to the topic! I try to implement this, when I have the time to it. I'm sure many people will find this useful.


New member
Jun 21, 2017
Happened to stumble on this thread while at the same time be flipping through some of my old website work and thought this might help, its the old(Read super old) php code I did for one of my first online score tables, I doubt much in the way of php has changed since then so it probably still works just replace the database info with what ever your using.

// Add Score URL


    $secret_string = "connor";

    $gamename = $_GET['gamename'];
    $gamepass = $_GET['gamepass'];
    $playername = $_GET['playername'];
    $playerscore = $_GET['playerscore'];
    $playerlevel = $_GET['playerlevel'];
    $difficulty = $_GET['difficulty'];
    $md5 = $_GET['md5'];

    $md5hash = md5($secret_string . $gamename . $gamepass . $playername . $playerscore . $playerlevel . $difficulty);

    // 001 : Wrong MD5 Hash
    // 002 : Wrong Username
    // 003 : Wrong Password
    // 004 : Wrong User or Pass
    // 005 : DATA BASE ERROR
    // 006 : DONE
    if($md5hash !== $md5) {
        // Wrong MD5.
        echo ("TRE:001");
        // Check the Game name and password first
        //Open the link to the database.
        $link = mysql_connect ("", "TeamRebellion", "fdesrhgwgd");
        mysql_select_db("TeamRebellion", $link);
        $result_check = mysql_query("SELECT * FROM `Score_games` WHERE `game`='$gamename'", $link) or die ('Entry not found : ' . mysql_error());
            //open a connection to mysql, machine, uid, pwd
                //SQL to insert a record
                $query  = "INSERT INTO `Score_scores` ( Game,Owner,Difficulty,Name,Score,Level,ID ) VALUES ('$gamename','$row_check[5]','$difficulty','$playername','$playerscore','$playerlevel','')";
                //$query="INSERT INTO table (date,title,heading,body,posted) VALUES ($date,$title,$heading,$body,$by)";
                //close the connection
                echo ("TRE:006");
            //Wrong User or pass
            echo ("TRE:004");
Top Bottom