Here I have provided some additional steps for you to try based on what we learned from Example 5. My next post will be a sample solution of these steps, although you will gain the most by creating a solution for yourself.
- Add a CSS stylesheet and link it to the other pages.
- Make the
edit_cart.php
script redirect back to the index page when add to cart is clicked from the index page, but redirect to the cart page otherwise. Add a link on the index page to go to the cart page, without adding a product. - Add a page header with links to the products and cart pages. Put it in a separate file and use PHP
include()
function to add it to the product and cart pages. - Make the header show the total number of items in the cart on any page.
- Add a Product table to your database to store additional product details such as description and price. (See Example 1 - Getting data from database)
- Make the Cart table
ProductID
field a foreign key to reference the primary key in the Product table. - Output the product details of all products in the database on the products page (
index.php
). - Add images of each product on the products page. You can either save them in the database or store image files with filenames of each associated product ID.
- Add payment input fields (eg card number, expiry date) to the checkout page and show them in the invoice.
- Validate the payment input to cancel the order if it is invalid. Send an error message in this case.
- Extract the email related code in the on_checkout.php file to a function and the same for the database saving code.
- In the on_checkout.php script, if the cart is empty, invalidate the purchase and return to the cart page.
- Change the invoice email to use an HTML content type. This will require additional email headers to be added.
Parent topic: Example 5
Top comments (0)