Here is part of my shopping cart project which I created during my PHP / MySQL studies. Needless to say it is good only for studying purposes because it is insecure and quite immature:
The funniest thing is that one of the requirements for this cart was to be in just 2 files. So because I couldn't imagine to fit it in two files I just fitted it in 2
Let the fun begin:
go back to the store and begin shopping :).'; // If post input with 'do' values is coming from the admin area forms we will process it here. This is because we have to use get otherwise the URL will become too long especially when we specify long description for products. switch ($_POST['do']) { case 'insert': $command = "insert into shop_products (prouct_name, price, product_image, description) values('".addslashes($_POST['product_name'])."','".addslashes($_POST['price'])."','".addslashes($_POST['product_image'])."','".addslashes($_POST['description'])."');"; $result = mysql_query($command); print "Data was successfully entered. "; mysql_close($db); exit(); break; case 'update': $command = "update shop_products set prouct_name='".addslashes($_POST['product_name'])."', price='".addslashes($_POST['price'])."', product_image='".addslashes($_POST['product_image'])."', description='".addslashes($_POST['description'])."' where product_id='".$_POST['product']."';"; $result = mysql_query($command); print "Data was successfully updated. "; mysql_close($db); exit(); break; } //Since we are limited to the number of pages we will use switch to simulate all the pages we want :) <a href="http://linux.bgsnow.com/shopping-cart-in-php.php#more-223" class="more-link">Read the rest of this entry »</a>