Creating your own Leaderboard / Highscores Easy and Free (PHP & MySQL) [UPDATED 2020]

  • 69 favourites


Attached Files

The following files have been attached to this tutorial:



Download now 180.37 KB


31,290 visits, 85,265 views



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

PHP to Read and Write Scores

Go to your Dashboard and access your File Manager. Here you can upload files, images, sounds, games, etc... This is where the PHP files will be saved (the ones you downloaded attached to this tutorial).

You should click "public_html" directory and upload there your files and folders. To Upload your PHP files, click the "Upload" button and select 'savescores.php' and 'getscores.php' and 'login.php'. You can also upload a zip file and extract it once uploaded.

Edit Your Database Connection Info

Edit the PHP file 'login.php' and update the database part according to the data of your account - like the image shown below. Then save the changes.

(You can also find this data on your Dashboard Tools -> Database Manager)

Reading Scores (testing our PHP)

To read your highscores, we use the file 'getscores.php'.

Type on your internet browser (Google Chrome, Firefox, etc) your free domain + the path to 'getscores.php'.

For example, my URL to read scores is:

If you can see the 'best scores' you previously saved on the database, you have set it up correctly. Congratulations! :)

Writing Scores

You save scores calling the 'savescores.php' file in your website. For example, to save 'John' and '51' points, we will call from Construct 2 the following URL:

Save a new score using the 'savescores.php'.

Then try 'getscores.php' again. If you can see the new score you just saved on the database, you have everything ready!

The server part is ready. Now you only need to set up Construct 2!


  • Order by
Want to leave a comment? Login or Register an account!
  • [FIXED] The scripts save/get should be updated according to the latest PHP formatting rules. After fiddling after a bit I found that in the save.php you should remove the "id" parts when inserting the score.

  • Great tutorial for a refresher. Ive just finished reading through the tutorial and will soon be implementing the PHP.

  • Thanks for this super clear tutorial! I like your idea about separating the scores by 'level' or by 'difficulty' (easy, medium, hard). Do you have a tutorial for this? Thanks alot!!!!

    • First, your scores table must have a new column. So you have: name, score AND level/difficulty.

      Then, when submitting score to savescores.php, you already sent name & score. Now you must also add the new variable: level/difficulty.

      Last, when getting scores with getscores.php, let's say you will read only scores for level 2 or difficulty easy.

      You can send a variable level/difficulty from the game to getscores.php. Edit the getscores.php PHP file to read from the Database only the scores with the requested level/difficulty.

  • hello, I have successfully created Hiscore with this tutorial. But I have a problem when I want to update the database or delete it.

    Can you please help how to update and delete the database?

  • Hi! Thanks a lot for this tutorial and for giving us the example projects and folders! This is really what users want!

    Could you please explain how could I improve/edit the design of the leaderboard tables? What would be the method? I there a way I can create the design on a software like Dreamweaver and have this php/mysql leaderboard implemented? Ou maybe even edit the design as a page/post on Wordpress?

    Lastly, would you be wiling to help me doing this for a work project of mine? Off course I'll be glad to pay something.

    All the best,

  • Load more comments (92 replies)