View Full Version : Anyone know a good tutorial for a shopping cart without a database?

11-24-2006, 03:00 PM
I've just started learning php and I need a shopping cart which doesn't rely on a database. I can't find any tutorials where this is the case. I'm going to learn it with a database soon, but the site I am doing at the moment doesn't need it.

Basically there are a few things which will be made once sold, so don't require a db. All i need really is a php page which stores whatever is sent to it via a link. So it doesn't even have to be a shopping cart!

Can anyone point me in the right direction?


11-25-2006, 04:50 AM
you should learn how to use a database. It's actually easy to do stuff with that then without a database. That's why they are there :)

The closest thing I can think of is store things in the link.
i.e. index.php?a=x

would store the value x in a. So, use $_GET['a'] to get the value of x, whether you need it. To add more values, just rewrite the link.

11-25-2006, 05:46 PM
store the purchases in a session ..e.g.


that way you dont have to keep passing the variables around.. remember to use session_start(); on any pages that need access to the data.

you can even store the session data for later use ...

/*save it*/
$save = serialize($_SESSION['CART']);

/*reopen it*/