Server Side Programming
Shopping Cart
November 2016
The aim of this project was to create a shopping cart system, using OOP (Object Oriented Programming) conventions for PHP. This system needed to allow users to register as customers, and save items to their shopping cart. Upon placing the order, and email needed to be sent to the website owner, and a receipt sent to the customer. This project was created using HTML, CSS, PHP, SQL, PDO and mPDF.
View Project Development View WebsiteInteresting Parts
- All receipts for orders are exported as PDFs using the mPDF library. These PDFs can be viewed in browser, or downloaded
- When registering for an account, validations are being sent to the server for inputs such as the username, to ensure that it is valid before submitting i.e. can't start with "_", is it available etc.
- The shopping cart is maintained across pages using sessions, and stores only the id and quantity of each product - the rest is sourced from the database
- Custom pagination was created for displaying the products, and is responsive to the number visible and remaining products to view
What I learned
- As this the first PHP project I had built from scratch, I learned a lot about the syntax, conventions and quirks of PHP for example, that initialising an array using square brackets "[]" has only been supported since PHP 5.4, prior to which "array()" was required (important depending on the PHP version running on your server).
- Through use of the mPDF library, I learned how to generate PDFs dynamically, and return them to the user in a variety of forms i.e. to view, download and download with a custom file name
- I learned how use an OOP (Object Oriented Programming) approach, when working with PHP. This was hugely beneficial, as it allowed me to reuse code blocks throughout the server, without duplication