kid_drew Posted July 25, 2007 Share Posted July 25, 2007 Hey guys, I'm trying to code up a simple game where the user passes from one page to the next through a series of links. How can I prevent a user from cheating by typing in the URL of a page that is not in the logical flow of the game? Some kind of cookie trick, I'm sure, but I can't seem to wrap my head around it. -Drew Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 25, 2007 Share Posted July 25, 2007 <?php session_start(); $_SESSION['x']="not cheating"; ?> <?php session_start(); if($_SESSION['x']=="not cheating"){ // game }else{ echo" you cheat"; } ?> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 25, 2007 Share Posted July 25, 2007 a session containing the page number so... if the person is on page 2 it would look like this: http://mysite.com/mypage.php?page=2 <?php if($_SESSION['page'] < $_GET['page']){ header('Location: /mypage.php?page='.$_SESSION['page']); exit; }else{ //display the page } ?> then when they advance, you need to incrament the session page number by 1 <?php $_SESSION['page']++; ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 25, 2007 Share Posted July 25, 2007 Basically what redarrow means is, use sessions. :-) <?php session_start(); if($_SESSION['step'] != $_GET['page']) { header("location: index.php?page=".$_SESSION['step']."");exit; } else { $_SESSION['step']++; } ?> But the approach and code depends on how you're moving them from page to page (Or step...wtvr) Edit: Wow...typo :-P Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.