If the user completes the level and then remains on the same page, that does the extra work:
Then you probably want Ajax to send new level information to the server as soon as a new level is reached. In this way:
Use cookies to store your php session id
From your Javascript client, use Ajax to call the php url on your server whenever the user wins a new level. Send a new level as a parameter. Can use POST or GET, it does not matter.
The php program will receive the session identifier in the cookie, and a new level as the parameter. The php program looks up the user id from the session id and then saves the new database level.
The next time the php program main URL is called, it will be able to search for the user level.
If the user clicks the Next button to go to the next level: Use Javascript, not Ajax, to change the POST settings of the Next button.
You are using POST, not GET, as browsing the foo.com/game?level=5 URL is too obvious for people to trick your game into. POST does not display the level parameter in the url. Extra security: Add a checksum parameter.
If any of the above questions is not clear, ask in the comments or as a follow-up question.
source share