0

I own a text based game, it is the first website I've created from scratch with php/html. Recently my players have found that they can just leave an auto-refresher on certain pages and just keep increasing their stats. I've realised that there are a number of pages that they can leave the auto-refresher on and simply become incredibly strong by cheating.

I want to know if there's any ways of preventing auto-refreshers while not affecting gameplay. Captcha codes could be used but they would seriously make the game unplayable as they'd be on pretty much every page.

Best thing I can think of is a way to simply prevent the refreshing so the only way that the user can earn the reward is by clicking the button.

At the moment I use POST, is it possible to prevent POST from working if it's just a refresh?

Ben
  • 101
  • 1
  • 11
  • Prevent form resubmission: http://stackoverflow.com/questions/6320113/how-to-prevent-form-resubmission-when-page-is-refreshed-via-php – Daan Dec 09 '14 at 10:41
  • You could add a hiddden variable in your forms with a datetime value or a unique string. If you reprocess a form with the same hidden variable you could just ignore it – Serpes Dec 09 '14 at 10:47
  • @Serpes That sounds perfect. I will give that a shot! EDIT How do I add a hidden variable? – Ben Dec 09 '14 at 10:51
  • @Daan I can do that but that'd mean me turning 1 page into 3, for 10 different pages. Or is that just what I have to do? – Ben Dec 09 '14 at 11:00
  • @Ben You could do it in one page look at my answer below. – Daan Dec 09 '14 at 11:07
  • @Serpes I have got it sorted. Thanks dude, you really don't know how much you've helped me :D – Ben Dec 09 '14 at 11:13

1 Answers1

0

Use the post/redirect/get pattern:

if ($_POST) {
   // Execute code (such as database updates) here.

   // Redirect to this page.
   header("Location: " . $_SERVER['REQUEST_URI']);
   exit();
} 
Daan
  • 12,099
  • 6
  • 34
  • 51