Page 1 of 1

"Add to cart" function, need help...

Posted: Thu Oct 27, 2005 7:55 pm
by WithHisStripes
Heya,
So I need to build a VERY simple "add to cart" function but I don't know where to begin. What I have is a site that has four pop up JS windows with just a few products. What I want to do is have a check box next to each product within each window and then a "add to cart" button at the bottom of the page. I need that button to send the titles of the checked boxes (ie shirt, cd, book, etc...) to another page on the site where they can view their order, after that, I know what to do. Can anyone help?! Thanks!

-Spence

Posted: Thu Oct 27, 2005 8:09 pm
by hawleyjr
Use sessions to send the variables from page to page.

Posted: Thu Oct 27, 2005 8:12 pm
by feyd
suggestion: don't use popups.

an "add to cart" link/button/whatever most often simply stores the product(s) id(s) (maybe a quantity, a size, whatever else) into an order items table that is associated with an order record.

Posted: Thu Oct 27, 2005 8:15 pm
by WithHisStripes
Thanks guys for the input, I understand that pop ups aren't the best way to do it, but I'd like to give it a try if it's possible. Now, about using sessions, I understand php code pretty easily but I don't write it well, so really, I don't know where to begin in writing the code, could you give me an example code or maybe point me to some resources? Thanks SO much guys!

-Spence

Posted: Thu Oct 27, 2005 8:18 pm
by hawleyjr
Simple sessions test:

Code: Select all

page1.php


<?php
session_start();

$_SESSION['MY_COUNTER']++;


echo 'Counter: ' . $_SESSION['MY_COUNTER'];

?>

<a href="page2.php">Page 2</a>

Code: Select all

page2.php


<?php
session_start();

$_SESSION['MY_COUNTER']++;


echo 'Counter: ' . $_SESSION['MY_COUNTER'];

?>


<a href="page1.php">Page 1</a>

Posted: Thu Oct 27, 2005 8:54 pm
by WithHisStripes
Okay, so if I am right, those pages are sharing information with each other via the mycounter session. And mycounter acts as the cookie by storing their order?
Now how do I create the page where that information is stored? Thanks!