A fully-featured, professional Inventory Management System built with pure PHP, MySQL, HTML, and CSS β no frameworks. Designed to demonstrate real-world web development skills including authentication, API integration, responsive design, and business logic.
Guest Access: Visit any page without login to browse Admin Access: Register an account to unlock full features
- User Registration & Login
- Session-based authentication
- Guest mode β browse without login
- Role-based access control
- Secure password hashing (bcrypt)
- Add, Edit, Delete products
- SKU auto-generation system
- Product image upload
- Category management
- Supplier linking
- Real-time stats cards (Total Products, Total Value, Low Stock, Categories)
- Low stock alerts panel
- Recently added products panel
- Stock In / Stock Out tracking
- Stock movement history
- Automatic quantity updates
- Low stock warnings (β€5 units)
- Add and manage suppliers
- Link products to suppliers
- Track supplier contact info
- Add, Edit, Delete categories
- Product count per category
- Protected deletion (can't delete if products exist)
- Inventory by category with value share bars
- Most valuable products
- Most/least stocked products
- Stock movement summary
- Search by product name or SKU
- Filter by category
- Real-time results
- Export to CSV
- Print-friendly layout
- Bulk delete products
- 10 products per page
- Dynamic page navigation
- ExchangeRate API β Real-time currency conversion (USD to PKR, EUR, GBP, AED, SAR, and more)
- Barcode API β Auto-generated barcodes for every product SKU (downloadable + printable)
- Gmail SMTP (PHPMailer) β Automated low stock alert emails
- Mobile-friendly hamburger menu
- Tablet and desktop optimized
- Print stylesheet included
- Tracks every user action
- Timestamps for all events
- Clearable log history
| Technology | Usage |
|---|---|
| PHP 8.2 | Backend logic, sessions, file handling |
| MySQL | Database (mysqli with prepared statements) |
| HTML5 | Structure and markup |
| CSS3 | Custom styling, responsive design, animations |
| PHPMailer | Email alerts via Gmail SMTP |
| ExchangeRate API | Live currency conversion |
| Barcode API | Product barcode generation |
| Composer | PHP dependency management |
- Prepared statements (SQL injection prevention)
- Password hashing with
password_hash()(bcrypt) - Session-based authentication
- XSS prevention with
htmlspecialchars() - File upload validation (type + size)
- CSRF-safe form handling
- Input sanitization on all forms
inventory-system/
βββ auth.php # Session authentication guard
βββ dashboard.php # Main dashboard with stats
βββ products.php # Product listing, search, filter, export
βββ add.php # Add new product with image upload
βββ edit.php # Edit existing product
βββ delete.php # Delete product
βββ stock.php # Stock In/Out management
βββ suppliers.php # Supplier management
βββ categories.php # Category management
βββ currency.php # Currency conversion (API)
βββ barcode.php # Barcode generator (API)
βββ email_alerts.php # Low stock email alerts (API)
βββ reports.php # Inventory reports
βββ activity.php # Activity log
βββ login.php # User login
βββ register.php # User registration
βββ logout.php # Session logout
βββ sidebar.php # Shared navigation component
βββ style.css # Complete stylesheet
βββ db.php # Database connection (excluded from repo)
βββ uploads/ # Product images (excluded from repo)
- XAMPP (Apache + MySQL + PHP 8.x)
- Composer
- Gmail account with App Password (for email alerts)
1. Clone the repository
git clone https://github.com/sn123686-dev/inventory-system.git
cd inventory-system2. Install dependencies
composer install3. Create the database
Open phpMyAdmin and run:
CREATE DATABASE inventory_db;
USE inventory_db;
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
sku VARCHAR(50) UNIQUE,
category VARCHAR(100) NOT NULL,
supplier_id INT NULL,
quantity INT NOT NULL,
price DECIMAL(10,2) NOT NULL,
image VARCHAR(255) NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE categories (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE suppliers (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100),
phone VARCHAR(20),
address TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE stock_movements (
id INT AUTO_INCREMENT PRIMARY KEY,
product_id INT NOT NULL,
type ENUM('in', 'out') NOT NULL,
quantity INT NOT NULL,
note VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE
);
CREATE TABLE activity_log (
id INT AUTO_INCREMENT PRIMARY KEY,
action VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'user') DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);4. Create db.php
Create a file called db.php in the project root:
<?php
$host = "localhost";
$username = "root";
$password = "";
$database = "inventory_db";
$conn = mysqli_connect($host, $username, $password, $database);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>5. Create uploads folder
mkdir uploads6. Run on localhost
Place the project in C:\xampp\htdocs\inventory-system\ and visit:
http://localhost/inventory-system/login.php
- Sign up free at exchangerate-api.com
- Get your API key
- Add it to
currency.php
- No setup needed β uses barcodeapi.org (free, no key required)
- Enable 2-Step Verification on your Gmail
- Go to Google Account β Security β App Passwords
- Create an App Password
- Enter it in the Email Alerts page when sending
Saima Nadeem
- GitHub: @sn123686-dev
- Location: Islamabad, Pakistan
This project is open source and available under the MIT License.



