tailieunhanh - PHP and MySQL Web Development - P109

PHP and MySQL Web Development - P109: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 512 Chapter 25 Building a Shopping Cart When they have finished shopping we will need to be able to total up their order take their delivery details and process their payment. We should also build an administrator interface to Book-O-Rama s site so that the administrator can add and edit books and categories on the site. Solution Components Let s look at the solutions to meeting each of the requirements listed previously. Building an Online Catalog We already have a database for the Book-O-Rama catalog. However it will probably need some alterations and additions for this application. One of these will be to add categories of books as stated in the requirements. We ll also need to add some information to our existing database about shipping addresses payment details and so on. We already know how to build an interface to a MySQL database using PHP so this part of the solution should be pretty easy. Tracking a User s Purchases While She Shops There are two basic ways we can track a user s purchases while she shops. One is to put her selections into our database and the other is to use a session variable. Using a session variable to track selections from page to page will be easier to write as it will not require us to constantly query the database for this information. It will also avoid the situation where we end up with a lot ofjunk data in the database from users who are just browsing and change their minds. We need therefore to design a session variable or set of variables to store a user s selections. When a user finishes shopping and pays for her purchases we will put this information in our database as a record of the transaction. We can also use this data to give a summary of the current state of the cart in one corner of the page so a user knows at any given time how much she is planning to spend. Payment In this project we will add up the user s order and take the delivery details. We will not actually process payments. Many many payment systems are .

TỪ KHÓA LIÊN QUAN