Best way to go about this? [PHP]

Soldato
Joined
25 Oct 2006
Posts
5,395
Hi all

So I need to make an order form which lists a few products, you select quantity and then postage choice and then checkout and ask customer for address and CC details. Finally display an order confirmation.

My query is about storing the user's choices and the products. I was thinking create an array to store each product and its price, for listing them in form. Then to carry that information to the order confirmation I could use a multi-dimensional array to store the price, product, and quantity ordered. Is there a better way or a good way without using multi-dimensional arrays?

Thanks!

P.S. It's only a basic order form, not going to be used in a live environment at all.
 
If you're just creating a basic form the simplest thing to do would be to use $_POST to retrieve all of the values posted in the form. If you need to carry the data over multiple pages you could assign the $_POST vars to $_SESSION data. If I've understood correctly I believe that would be the simplest way to do it :)
 
so a var for each product? This doesn't seem particularly expandable, and if I have lots of products will mean lots of vars.

I would rather not use sessions or databases in this example.
 
If you don't want to use a DB, no idea why even in a dev enviroment, then a multidimensional array is the 'best' solution. Still pretty messy though. And yes, use sessions for storing info between pages.
 
Back
Top Bottom