Jump to content

reset after refresh


sai

Recommended Posts

Hi.

 

I created a dice game in PHP, that randomly generates dice. My problem is that if the player does not like his/her dice, they can refresh or use the back buttons on the browser to generate new dice.

 

What code can I put so that if the player clicks the refresh or back button, the browser would stop it, or redirect them to another page?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/58572-reset-after-refresh/
Share on other sites

you can set a SESSION variable when they get their dice, and check for that before you assign a set.  if the SESSION var is there, don't show them dice (and consequently do what you want: redirect, give an error, etc.), otherwise assign a set.

 

if you're tracking them via a database or some other means, then simply add a flag to their specific information set to say they've already been assigned their dice.

Link to comment
https://forums.phpfreaks.com/topic/58572-reset-after-refresh/#findComment-290539
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.