Ordering Items

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Ordering Items

Post by AliasBDI »

I am building a photographer's web site where he offers his clients the option of placing an order online. It is not an eCommerce store, but simulates like one. There is no money transactions going on. The user will navigate to a photo and then add to cart. The items are kept in a SESSION on the server and then the user can go shop for more photos. Once the shopping is completed the user sends the order to the photographer via a form which has been collecting everything they have ordered.

Here is a link to a page where you will see the photo to purchase and the selections/options of what to order from that photo. (http://www.sc-photo.com/order/browsePho ... 27&pID=316)

The navigation is working fine. Here is my problem. I have no idea how to make the forms on this page submit SESSION variables of the selected data (photoID, clientID, photoSIZE(s), etc. (you can see the options on the form). Where should I begin? Where should I turn to get some sort of guidance and direction?

Thanks.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

echo '<input type="hidden" name="something" value="'.$_SESSION['something'].'">';
Use hidden form fields like that and set the value from the SESSION. Submit the form via POST, along with any other user input fields you need. Then you have everything you need. You could also just keep them in SESSION and read them from SESSION again at the processing page.

EDIT | Oh I see.... yes, use hidden form fields. If you need to keep info bundled together you can set your names to be arrays....

Code: Select all

echo '<input type="hidden" name="item['.$_SESSION['id'].']" value="'.$_SESSION['item'].'">';
echo '<input type="hidden" name="size['.$_SESSION['id'].']" value="'.$_SESSION['size'].'">';

//after posting you'd have something like
// $_POST['item'][8743] = 'Red Lantern Photo';
// $_POST['size'][8743] = '6x4';
Post Reply