Integrating the Cart with Your Storefront

In this section, you'll make modifications to the showitem.php script from Chapter 20, “Creating an Online Storefront.” The goal is to transform the item information page into an item information page with a form for selecting colors, sizes, and quantities.

In the original script, insert the following before line 2:

session_start();

Because the shopping cart elements are attached to the user through a session ID, the session must be started. The next changes don't occur until what was line 37 of the original script, so that's where we start Listing 21.1.

Listing 21.1. New Lines in showitem.php
 37:        <P><strong>Price:</strong> \$$item_price</p> 38: <form method=post action=\"addtocart.php\">"; 39: //get ...

Get Sams Teach Yourself PHP, MySQL® and Apache All in One now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.