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

6
  • 38 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.zip
.capx

highscore-example.capx

Download now 180.37 KB

Stats

23,024 visits, 61,482 views

Tools

In this tutorial you will learn how to create your own Highscores for your games, using your own free server / database. Let's go!

What do you need?

- Your Construct 2 game (or C3)

- A server with PHP and MySQL databases (you can get a free server on 000webhost.com)

- Download the PHP7 files (phps.zip is for older versions of php5)

Let's start, step by step...

Registrating Your New Free Server

A server is like a computer on internet where you can save your own data: pictures, files, databases, scores, games and many more things...

000webhost.com offers free web hosting, with PHP and MySQL. It allows you to create 1 free website, host your files and you can create 2 free Databases.

Go to http://www.000webhost.com. Click "Sign Up" and register as a new user.

Fill your name, email and select a new password. When you are done you will receive a confirmation email, open your email account and Confirm your registration.

Back to 000webhost, select Create a New Site. Then type a name for your free domain, ie: duquekarlgames.000webhostapp.com

The next step is to access your dashboard.

Access your Dashboard

If you have already signed up and confirmed your free account, then you can log in to your account. To access your Dashboard, click Manage Your Website.

  • 34 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Great tutorial for a refresher. Ive just finished reading through the tutorial and will soon be implementing the PHP.

  • [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.

  • Thank you so much for posting this! I got this to work with construct 3 and now im integrating the code with my custom name writing and text graphics. (Any thing system font is ugly on any device).

    Also a great way to learn interaction with construct 3 and a server.

    • Great! Yes, it should work in C3 as well.

      If you liked my tutorial, give it some love! A thumbs up or Favorite, so it can help others too ;)

  • Is there anyway for me to change the code so that is will give you the lowest scores as my game doesn't have a score but rather a speed run clock that goes up the longer you take to finish. So my "high scores" need to be the ones with the lowest values can you help me at all with where and what in the code I need to change?

    • Yes!

      Open 'getscores.php' and replace "ORDER BY score DESC" (scores are ordered DESCending - higher first then lower) with "ORDER BY score ASC" (scores will be ordered ASCending - lowest values first, then higher)

      // Retrieve data from database

      $sql = "SELECT *

      FROM scores

      ORDER BY score DESC // Replace 'DESC' with 'ASC'

      LIMIT 10"; // The 'LIMIT 10' part will only read 10 scores. Feel free to change this value

    • [-] [+]
    • 2
    • Do2's avatar
    • Do2
    • 2 points
    • (0 children)

    Thanks!

  • Load more comments (27 replies)