ChidoriSoul Posted June 7, 2009 Share Posted June 7, 2009 Ok, so I am trying to make a basic well, treasure hunt, in PHP. I would want it to have so that it would be on the same page, and every time you click search, it generates the same page, excpet with a different outcome.Also, it could not be where people could not just change the link in the address bar so they could find the answer immediatlly Link to comment Share on other sites More sharing options...
boen_robot Posted June 7, 2009 Share Posted June 7, 2009 If the users are logging in before they start the treasure hunt, you can use the $_SESSION to keep track of their attempts.To generate the random number, you can use mt_rand() with proper min and max values of course.You should also have a condition whereby if they've already tried that number, it tries to generate one again.To do all that, you can use something like: $makeAttempt = true;$attempt;while($makeAttempt) { $attempt = mt_rand(0, 15);//assuming you have 15 possibilities $makeAttempt = in_array($attempt, $_SESSION['attempts']);}$_SESSION['attempts'][] = $attempt; Link to comment Share on other sites More sharing options...
ChidoriSoul Posted June 7, 2009 Author Share Posted June 7, 2009 Ok, now how can I customize the each prize to a page Link to comment Share on other sites More sharing options...
boen_robot Posted June 7, 2009 Share Posted June 7, 2009 Ok, now how can I customize the each prize to a pageWith the session again. Have two separate variables telling the price, and it's right number. Then verify the attempt against the right number, and give the price if correct.The point is - everything that must be preserved across requests - store it in the session. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.