This project is a custom-built, lightweight backend system for managing an E-commerce platform. Developed primarily to demonstrate secure database interaction, the entire data layer is engineered using 100% Parameterized Queries (Prepared Statements) to completely eliminate SQL Injection vulnerabilities.
The application follows a structured MVC (Model-View-Controller) approach, separating the business logic, data access, and user interface into dedicated modules for better maintainability and code clarity.
- π‘οΈ Security First: Strict implementation of
mysqli_stmtfor every single CRUD operation. No user input is ever directly concatenated into an SQL string. - π Atomic Transactions: Complex operations, such as creating a new order with multiple items, are handled via true SQL Transactions (
begin_transaction,commit,rollback). This guarantees database integrity: if one query fails, the entire order is aborted. - π§© Advanced SQL Logic: Implements relational queries using complex
JOINs, data aggregation (SUM()), and safe string matching (LIKE). - π¦ Inventory Management: Dynamic update of product stock quantities directly via mathematical operations at the SQL level.
- π¨ Clean UI: Responsive and user-friendly interface powered by Bootstrap 5, operating through a central routing hub.
The repository is organized following an MVC pattern:
/
βββ index.php # Main entry point and initialization
βββ controller/ # Routing and input handling
β βββ sorter.php # Central router matching user actions to controllers
β βββ new_order.php # Handles order creation requests
β βββ update_stocks.php # Handles inventory updates
β βββ ... # Other specific controllers
βββ model/ # Database configuration and logic
β βββ db_config.php # MySQL connection setup
β βββ data.php # Core data access functions (Prepared Statements)
β βββ ecommerce_db.sql # Database schema and mock data
βββ view/ # User Interface
βββ home_view.php # Main interactive dashboard (Bootstrap)
The relational database (negozio_online) consists of 4 main tables handling the e-commerce flow:
utenti(Users): Stores user credentials and personal data.prodotti(Products): Inventory registry holding prices, descriptions, and stock quantities.ordini(Orders): Tracks individual purchases, linking a user to a total spent amount and status.dettagli_ordine(Order Details): A many-to-many resolution table linking an order to its specific products, freezing the unit price at the time of purchase.
(Includes cascading deletes to maintain referential integrity when users or orders are removed).