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

  • 80 favourites


Attached Files

The following files have been attached to this tutorial:



Download now 180.37 KB


41,217 visits, 110,713 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.

  • I may be a bit late to the party, but I just finished this great tutorial by the letter, but the construct 3 part did not work. "work" means, no data was retreived after the ajax request. The phps work just fine, so I went bugfixing. as some users here seem to have similar problems, I want to share my solution:

    Instead of using a constant for the URL as suggested in the tutorial, i hardcoded it in the ajax request. this works like a charm. maybe it helps somebody else :-)

    thank you, dear author of this fine tutorial. well written and a huge help.

    • Hey! Thanks for writing and I am happy that you enjoyed the tutorial and it was helpful!! Go and make some super awesome games and share them here later! ;)

      • Hi, thanks fo the wonderful tutorial but I have an Issue, I hope you can help me by getting block issue in CORS

        how do I deal with it?

        how do I implement the code that allowing me to access in different site address?

  • Thankyou DuqueKarl for putting together this Tutorial. Very helpful

  • thank you for the tutorial it was very helpful in my game development

  • Load more comments (103 replies)