This project is a minimal but fully functional web-based Inventory Management System (IMS) built using PHP, MySQL, and basic CSS/JavaScript.
It is designed to demonstrate fundamental web development concepts, including user authentication, **session management, **database transaction handling, and **role-based access control (RBAC).
The system supports three primary user roles: Admin, Staff, and Supplier.
- Role-Based Access Control (RBAC): Restricts page access based on user role (admin, staff, supplier).
 - Secure Authentication: Uses password_verify() for secure login and session management.
 - Product Management: Admin/Staff users can add, view, edit, and delete products.
 - Real-time Stock Tracking: Sales automatically decrement product stock.
 - Low Stock Alerts: Identifies products falling below a set threshold.
 - Sales Module: Dedicated transaction page for staff to quickly record sales.
 - Dashboard: Provides key metrics, including daily revenue and low stock counts.
 
The project follows a modular and organized structure:
SQL_Project_2.0/
├── assets
│   ├── css
│   │   └── styles.css
│   └── js
│       └── scripts.js
├── ims_database.sql
├── includes
│   ├── db_connect.php
│   ├── footer.php
│   ├── functions.php
│   └── header.php
├── index.php
├── login.php
├── logout.php
├── pages
│   ├── admin
│   │   ├── admin_dashboard.php
│   │   ├── manage_users.php
│   │   └── user_form.php
│   ├── inventory
│   │   ├── low_stock.php
│   │   ├── product_form.php
│   │   └── products.php
│   └── sales
│       ├── sales_history.php
│       └── sales.php
└── README.mdFollow these steps to deploy and run the application locally:
- Web Server (Apache, Nginx)
 - PHP (7.4 or higher)
 - MySQL/MariaDB
 
- 
Access your MySQL/MariaDB terminal (e.g., mysql -u root -p).
 - 
Execute the provided SQL script to create the database (inventory_db_2) and populate it with tables and default users: bash source /path/to/your/project/ims_database.sql
 - 
Create Database User: Ensure the webuser and webpass credentials match those defined in includes/db_connect.php: sql CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'webpass'; GRANT ALL PRIVILEGES ON inventory_db_2.* TO 'webuser'@'localhost'; FLUSH PRIVILEGES;
 
- 
Copy the entire project folder to your web server's root directory. If you are using a subdirectory (e.g., /var/www/html/SQL_Project_2.0), make sure the BASE_PATH in includes/functions.php is correctly set:
php // includes/functions.php define('BASE_PATH', '/SQL_Project_2.0/'); // Must match your deployment folder
 - 
Ensure the web server has read/write permissions for the project directory:
bash
sudo chown -R www-data:www-data /var/www/html/SQL_Project_2.0 sudo chmod -R 755 /var/www/html/SQL_Project_2.0
 
Open your browser and navigate to:
http://localhost/SQL_Project_2.0/
The ims_database.sql file includes the following default users:
| Username | Password | Role | Access | 
|---|---|---|---|
| admin1 | password | Admin | Full access to users, products, and sales. | 
| staff1 | password | Staff | Access to products, sales, and low stock reports. | 
| supplier1 | password | Supplier | Access limited to their assigned orders/low stock alerts. | 
(Note: The default password 'password' is hashed using bcrypt for security in the database.)