A class project of mine: a four-page e-commerce-type application. I hope this code sample is of use to someone else as well.
This project demonstrates the "POST-REDIRECT-GET" technique. The assignment was to create a four page e-commerce app with the following stages:
- Select your products and add them to your cart.
- Add your billing info.
- Re-display the order information and allow confirmation.
- Confirmation message.
Form inputs are validated at each stage. No errors or warnings should occur from pressing the back button in the browser or refreshing the page.
The configuration settings for the database are found in includes/config.php
. After
creating the database and adding your configuration settings, you can run the script
create_tables\create_tables.php
to set up the following database tables:
- products (the available products)
- orders (initially empty, entry created for each submitted order)
- order_item (initially empty, entry created for each order line item)
The project also includes some object oriented programming, using classes to represent
the shopping cart and products. Also included are a FormValidation class and a database
wrapper class for mysqli to make it easier to retrieve records as objects. includes/class/ApplicationDB
extends includes/class/Database.php
with several helper methods specific to the project.