Question

I'm making a web-quiz, there are the users logged in this game and they have to reply to a quiz with 3 alternatives, the problem comes when the user is a bit clever because if he does a refresh all the question change so the user can do this until he find the one that he knows, how can I put in my website (after an alert) wrong question? example:

  1. USA is in EU
  2. UK is in Africa
  3. France is in EU

If the users does a refresh, how can I show message such as alert("if you refresh is a game over") and save the answer as incorrect in the database?

Was it helpful?

Solution

I'd suggest assigning the question in PHP and storing which question you asked in a $_SESSION variable. That way when they refresh the page you can show them the same question until they answer it.

UPDATE

There is a caveat to this, if your user really is a smarty, they can delete their cookies and refresh the page, which would create a new session for them since session identifiers are saved as a cookie in PHP (by default).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top