...

View Full Version : Advice for passing 15-20 values across php pages



Tacomon
05-07-2006, 12:56 AM
Here's my scenario:

I'm creating a mini-game on my site where users can compete against each other. I have an initiate page, where you get a listing of your stats and your opponent's and a link to initiate the event. This link goes to an immediately redirecting page that enters the results of the event into the database. The redirect ends up at a results page.

event.php?initiate -> event.php?enterdb -> event.php?showresults

Assuming that I have around 15-20 values to pass across to the enterdb and showresults pages, what is the best way to go about this?

The options that I know of are:

- put all the values in the url query string (which would be quite lengthy)
- put all the values into an array and serialize/unserialize
- put all the values into a session and destroy it upon reaching the results page
- do one of the above to get the values to the enterdb page, and make a call to the database on the showresults page

Things I want to take into consideration:

- code speed/minimizing database calls
- protecting the values coming into the enterdb page to prevent abuse (entering custom values)

firepages
05-07-2006, 03:53 AM
2 & 3 , serialize the data, store it in a session, the only `errr` is how much data are we talking about? , if its 15 or 20 mostly numeric values and small strings then thats probably fine, if you had fulltext data to pass around I would probably be putting that in the DB or a seperate flatfile.

Tacomon
05-07-2006, 05:14 AM
Thanks, firepages. :)

Almost all of the values are numeric. How server-intensive are sessions (assuming I'm only going to keep these particular ones open for a second or two)?

firepages
05-07-2006, 05:21 AM
They are not server-intensive as such (there could be some limits on the size of the session tmp directoy (unless you make your own session handler)) and you can keep lots of data in them thought they are primarily for keeping state in a stateless environment, there are better methods for storing fulltext & markup etc.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum