DEV Community

David Kanekanian
David Kanekanian

Posted on

E5 - Extra Steps

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.

  1. Add a CSS stylesheet and link it to the other pages.
  2. 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.
  3. 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.
  4. Make the header show the total number of items in the cart on any page.
  5. Add a Product table to your database to store additional product details such as description and price. (See Example 1 - Getting data from database)
  6. Make the Cart table ProductID field a foreign key to reference the primary key in the Product table.
  7. Output the product details of all products in the database on the products page (index.php).
  8. 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.
  9. Add payment input fields (eg card number, expiry date) to the checkout page and show them in the invoice.
  10. Validate the payment input to cancel the order if it is invalid. Send an error message in this case.
  11. Extract the email related code in the on_checkout.php file to a function and the same for the database saving code.
  12. In the on_checkout.php script, if the cart is empty, invalidate the purchase and return to the cart page.
  13. 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)