O'Reilly logo

Sams Teach Yourself CGI in 24 Hours, Second Edition by Rafe Colburn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Shopping Cart Script

The cart.pl program has two purposes—to list the contents of the user’s shopping cart and to remove items from the cart. When I kept everything in text files, this program was pretty complex because it had to correlate products listed in the cart.txt file with product information stored in the products.txt file. In this case, I use a single query to fetch the contents of the cart and the product information for each of the products in the cart at once. A delete statement is used to remove items from the user’s shopping cart. All of the database connection code in this script is identical to that in catalog.pl. In other words, I included the db_connect and db_cleanup subroutines, imported the DBI module, and set the variables ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required