Banning the user to visit a url before visiting a particular url?

+1 pratt 15 · July 14, 2014
I have made a quiz game using html & php and i have url as "localhost/game/ques1.php","localhost/game/ques2.php",i have used sessions in it but a user can go the next ques without answering ques1 by changing url from "localhost/game/ques1.php" to "localhost/game/ques2.php". How to stop user from doing that ??

Post a Reply

Replies

Oldest  Newest  Rating
0 Nikola Novakovic · July 21, 2014
You can also use some JavaScript tricks to check if the user has actually answered the question. 

If the user did not answer anything and is trying to change the url, pop up a simple alert or somethign that says that he MUST answer the question. For this it would be good to have Sumbit button on each question. 


This is just another layer of protection, you need to provide server side protection ( that is your first layer ) and then the second layer which is JavaScript. Anyone can turn off JS in their browsers ;)
0 Sachin Kumar · July 20, 2014
u can set the session and check that session on next question or u can use

$_SERVER['HTTP_REFERER']


super global to check the previous page url of the user :)
0 Alan Johnson · July 15, 2014
Keep track of what question number they are on and send them back to the appropriate question.
0 Pere Garau Burguera · July 15, 2014
I think you could probably set a session variable to true when the user answers quest 1 and then check that variable in quest 2.
+1 William Frost · July 15, 2014
You can put in the session something for telling what level he is and then check if he can view that level.
Code in pastebin http://pastebin.com/Lp9CgXmb


+1 Franz Schmidt · July 15, 2014
Its just an idea but you could make a session of the current website and a session of the site witch you can visit next.
  • 1

PHP

107,090 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators