php get, random records, and the back button

Posted by Andrew Heath on Stack Overflow See other posts from Stack Overflow or by Andrew Heath
Published on 2010-03-20T09:47:59Z Indexed on 2010/03/20 9:51 UTC
Read the original article Hit count: 413

Filed under:
|
|

My site has a library full of games, nations, game scenarios, etc.

library.php is given a type=___ & id=___

for example library.php?type=scenario&id=ABCD001

library.php saves the id to a session variable and loads an include appropriate for the type

This all works just dandy. Now, I wanted to give my users the option of pulling up a random scenario. To do that, I added a special id to the logic within lib-scenario.php (the include) such that if given library.php?type=scenario&id=random the include knows to run an alternate query for a random record rather than for the actual id

This also works just dandy... unless someone hits the Random Scenario button two+ times in a row, and decides that the previous random scenario was way cooler, I want to go back to that.

Because the http address is always directory/library.php?type=scenario&id=random no matter how many times you click Random Scenario, as soon as you click back you'll be taken to the last page with an alternate address you visited.

So, if you start at the Home page, and hit Random Scenario 35 times, then decide the 34th one was what you wanted and click BACK, you'll be put back onto the Home page.

I must admit this was not a problem I had anticipated. One of my testers was the first to have the urge to back-up in the random scenario stream and here we are.

How can I add back-up functionality to my script?

© Stack Overflow or respective owner

Related posts about php

Related posts about random