Version: 2.0
Last Updated: November 12, 2025
Status: In Development (Security Fixes in Progress)
- Overview
- Features
- System Requirements
- Installation Guide
- Database Setup
- Configuration
- User Roles & Permissions
- Security Status
- Password Reset Feature
- Notification System
- Blood Stock Management
- Testing Guide
- Troubleshooting
- Known Issues
- Changelog
A comprehensive web-based Blood Bank Management System designed to streamline blood donation, inventory management, and request handling. The system supports three primary user roles: Admin, Hospital, and User (Donors/Recipients).
- ✅ Complete blood stock management for hospitals
- ✅ User-to-user and user-to-hospital blood requests
- ✅ Real-time notifications system
- ✅ Blood donation tracking
- ✅ Password reset with OTP verification
- ✅ Responsive design with unified theme
⚠️ Security improvements in progress
- 📝 User registration and profile management
- 🩸 Request blood from hospitals
- 👥 Request blood from other users
- 💉 Donate blood to hospitals
- 🔔 Real-time notifications
- 📊 View donation and request history
- 🔍 Search available blood stock
- 🗺️ Hospital location map
- 🏥 Hospital registration and verification
- 📦 Blood stock management (add/edit/delete inventory)
- 📥 Receive and manage blood requests
- 📤 Accept blood donations
- ✅ Approve or reject requests/donations
- 🔔 Notification system for incoming requests
- 📊 Dashboard with statistics
- 📈 Low stock alerts
- 👤 User management (approve/reject/edit/delete)
- 🏥 Hospital management (approve/reject/edit/delete)
- 📊 System-wide reports and analytics
- 🔔 Notifications for pending approvals
- 🔒 System configuration
- 📈 View all blood requests and donations
- Web Server: Apache 2.4+ or Nginx
- PHP: 7.4 or higher (8.0+ recommended)
- Database: MySQL 5.7+ or MariaDB 10.4+
- Extensions Required:
- PDO or MySQLi
- mbstring
- openssl
- JSON
- cURL (for email)
- XAMPP 7.4+ / WAMP / LAMP / MAMP
- phpMyAdmin (recommended)
- Modern web browser (Chrome, Firefox, Edge, Safari)
# Clone from repository
git clone https://github.com/CERO-100/BloodBank.git
# Or download and extract ZIP file# For XAMPP
Move to: C:\xampp\htdocs\BloodBank
# For WAMP
Move to: C:\wamp64\www\BloodBank
# For LAMP (Linux)
Move to: /var/www/html/BloodBank- Start Apache and MySQL in XAMPP/WAMP
- Open phpMyAdmin:
http://localhost/phpmyadmin - Create Database: Click "New" → Name:
blood→ Create - Import SQL File:
- Click on
blooddatabase - Go to "Import" tab
- Choose file:
backups/blood_bank_complete.sql - Click "Go"
- Click on
Edit: includes/config.php or includes/db.php
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', ''); // Your MySQL password
define('DB_NAME', 'blood');Edit: includes/mailer.php
$mail->Username = 'your-email@gmail.com'; // Your Gmail
$mail->Password = 'your-16-char-app-password'; // Gmail App PasswordGet Gmail App Password:
- Go to https://myaccount.google.com/security
- Enable 2-Step Verification
- Create App Password for "Mail"
- Use the generated 16-character password
Main Site: http://localhost/BloodBank/
User Login: http://localhost/BloodBank/login.php
Admin Login: http://localhost/BloodBank/admin/admin_login.php
The system uses 6 main tables:
- admin_id (Primary Key)
- name
- email (Unique)
- password (Hashed with bcrypt)
- role (admin/superadmin)
- created_at- user_id (Primary Key)
- name
- email (Unique)
- password (Hashed)
- role (user/hospital/admin)
- phone
- blood_group (for users)
- location
- district
- latitude, longitude (for hospitals)
- status (pending/approved/rejected)
- created_at- stock_id (Primary Key)
- hospital_id (Foreign Key → users)
- blood_group (A+, A-, B+, B-, AB+, AB-, O+, O-)
- quantity
- updated_at- request_id (Primary Key)
- user_id (Foreign Key → users)
- hospital_id (Foreign Key → users) - For hospital requests
- donor_id (Foreign Key → users) - For user-to-user requests
- blood_group
- quantity
- status (pending/approved/rejected)
- created_at- donation_id (Primary Key)
- user_id (Foreign Key → users)
- hospital_id (Foreign Key → users)
- blood_group
- quantity
- status (pending/approved/rejected)
- created_at- id (Primary Key)
- user_id (Foreign Key → users)
- message
- type (user/hospital/donation/request/system)
- status (unread/read)
- created_at- ✅ Foreign key constraints for data integrity
- ✅ Indexes on frequently queried columns
- ✅ Proper enum types for status fields
- ✅ Automatic timestamps
- ✅ ON DELETE CASCADE/SET NULL for referential integrity
-
includes/config.php- Main configuration- Database credentials
- Site base URL
- Role constants
-
includes/db.php- Database connection- Alternative DB connection file
- Used in some older files
-
includes/mailer.php- Email configuration- SMTP settings
- Gmail credentials
- Email templates
-
includes/session.php- Session management- Session security functions
- Login/logout handlers
- Role-based access control
-
includes/functions.php- Utility functions- Input sanitization
- Flash messages
- Activity logging
Access: admin/admin_login.php
Default Credentials:
Email: tito@gmail.com
Password: [Check database - hashed]
Permissions:
- View all users and hospitals
- Approve/reject user registrations
- Approve/reject hospital registrations
- Edit user/hospital profiles
- Delete users/hospitals
- View system reports
- Manage system settings
- View all requests and donations
Files:
admin/admin.php- Dashboardadmin/manage_users.php- User managementadmin/manage_hospitals.php- Hospital managementadmin/view_requests.php- All requestsadmin/notifications.php- Admin notificationsadmin/reports.php- System reports
Access: login.php (role: hospital)
Default Credentials:
Email: testh@gmail.com
Password: [Check database]
Permissions:
- Manage blood stock (add/edit/delete)
- View incoming blood requests
- Approve/reject blood requests
- View incoming blood donations
- Approve/reject blood donations
- View dashboard statistics
- Update hospital profile
- Receive notifications
Files:
hospital/dashboard.php- Hospital dashboardhospital/stock.php- Blood stock managementhospital/requests.php- Manage requestshospital/donations.php- Manage donationshospital/notifications.php- Hospital notificationshospital/profile.php- Hospital profile
Access: login.php (role: user)
Default Credentials:
Email: jerin@gmail.com
Password: [Check database]
Permissions:
- Request blood from hospitals
- Request blood from other users
- Donate blood to hospitals
- View request/donation history
- Search available blood stock
- View hospital locations on map
- Update profile
- Receive notifications
Files:
user/dashboard.php- User dashboarduser/request_blood.php- Request from hospitaluser/request_public.php- Request from useruser/donate_blood.php- Donate blooduser/my_requests.php- Request historyuser/my_donations.php- Donation historyuser/notifications.php- User notificationsuser/profile.php- User profile
-
Password Security
- Bcrypt hashing (PASSWORD_DEFAULT)
- Minimum password length enforcement
- Password strength indicator
-
Session Security (Partial)
- Session regeneration on login
- IP address tracking
- User agent verification
- Auto-logout after inactivity (admin only)
-
Input Validation (Partial)
- Email validation
- Phone number format validation
- Blood group enum validation
- Integer type casting
-
SQL Injection Protection (IN PROGRESS)
- ✅ 8 files fixed with prepared statements
⚠️ 22+ files remaining with vulnerabilities
Status: 27% Fixed (8/30+ files)
Files Fixed:
- ✅
admin/approve_user.php - ✅
admin/approve_h.php - ✅
login.php - ✅
hospital/stock.php - ✅
includes/unified_header.php - ✅
user/donate_blood.php - ✅
user/profile.php
Files Requiring Fixes:
⚠️ user/request_blood.php⚠️ user/history.php⚠️ hospital/profile.php⚠️ hospital/header.php⚠️ hospital/dashboard.php⚠️ hospital/requests.php⚠️ hospital/donations.php⚠️ All admin delete/edit files⚠️ All notification files
Risk: Database compromise, data theft, unauthorized access
Status: Not Implemented
Affected Areas:
- All user approval/rejection forms
- Hospital management forms
- Blood stock management
- Profile update forms
- All CRUD operations
Risk: Cross-site request forgery attacks
Status: Partial Protection
Issues:
- Output not consistently escaped with
htmlspecialchars() - User-generated content not sanitized
- JavaScript injection possible in some forms
Risk: Session hijacking, malicious script execution
Fixed:
- ✅ Status check added (pending users blocked)
- ✅ Login redirect path corrected
- ✅ Session security improved
Remaining:
⚠️ No password reset attempts limit⚠️ No account lockout mechanism⚠️ Session timeout inconsistent across modules
Before Production:
- ✅ Fix all SQL injection vulnerabilities (Priority 1)
- ✅ Implement CSRF token system
- ✅ Add comprehensive XSS protection
- ✅ Implement rate limiting for login/password reset
- ✅ Add account lockout after failed attempts
- ✅ Enable HTTPS only
- ✅ Implement Content Security Policy (CSP)
- ✅ Add input validation on all forms
- ✅ Sanitize all database outputs
- ✅ Regular security audits
- Enter registered email address
- System generates 6-digit OTP
- OTP valid for 15 minutes
- Email sent via PHPMailer
- Enter 6-digit OTP from email
- Visual countdown timer (15:00)
- Paste support for easy input
- 3-attempt security limit
- Resend OTP option
- Enter new password
- Real-time strength indicator
- Requirements checklist:
- ✅ Minimum 6 characters
- ✅ Contains uppercase letter
- ✅ Contains lowercase letter
- ✅ Contains number
- ✅ Contains special character
- Password confirmation validation
Required: Gmail App Password
Setup:
- Enable 2-Step Verification on Gmail
- Go to App Passwords
- Generate password for "Mail"
- Add to
includes/mailer.php
Files:
forgot_password.php- Step 1verify_otp.php- Step 2reset_password.php- Step 3includes/mailer.php- Email configuration
- ✅ Real-time notifications for all users
- ✅ User-to-user request notifications
- ✅ Hospital request/donation notifications
- ✅ Admin approval notifications
- ✅ Unread count badges
- ✅ Mark as read functionality
- ✅ Notification types: user, hospital, donation, request, system
Location: user/notifications.php
Receives:
- Blood request responses from hospitals
- Blood request responses from other users
- Donation approval/rejection
- System announcements
Location: hospital/notifications.php
Receives:
- New blood requests from users
- New blood donation offers
- Stock low alerts
- System announcements
Location: admin/notifications.php
Receives:
- New user registrations (pending approval)
- New hospital registrations (pending approval)
- System alerts
- ✅ Add blood stock by blood group
- ✅ Update quantities
- ✅ Delete stock entries
- ✅ Visual dashboard with stat cards
- ✅ Low stock alerts (< 5 units)
- ✅ Color-coded indicators
- ✅ Real-time stock validation
-
User Requests Blood:
- User selects hospital
- System shows only available blood groups
- Quantity limited to available stock
-
Stock Validation:
- Client-side: Dynamic max quantity
- Server-side: Availability check
- Error if insufficient stock
-
Hospital Approves:
- Automatic stock deduction
- Notification sent to user
- Stock updated in real-time
-
Stock Indicators:
- 🟢 Green (≥5 units) - Good stock
- 🟡 Yellow (<5 units) - Low stock warning
- 🔴 Red (0 units) - Out of stock
- Total Units: Sum of all blood units
- Blood Types: Number of blood groups in stock
- Low Stock Alert: Count of low stock items
- Register new user with valid data
- Check user appears in admin panel
- Admin approves user
- User receives approval notification
- User can now login
- Pending user cannot login
- Register new hospital with location
- Check hospital in admin panel
- Admin approves hospital
- Hospital receives notification
- Hospital can login
- Hospital can access dashboard
- Hospital adds blood stock
- Stock appears in inventory
- Edit stock quantity
- Low stock alert shows for <5 units
- Delete stock entry
- Dashboard stats update
- User searches hospitals
- User sees only available blood
- User requests blood
- Hospital receives notification
- Hospital approves request
- Stock deducts automatically
- User receives approval notification
- User searches for donors
- User sends request to donor
- Donor receives notification
- Request appears in donor's notifications
- User donates to hospital
- Hospital receives notification
- Hospital approves donation
- User receives confirmation
- Stock increases (if implemented)
- Click "Forgot Password"
- Enter email, receive OTP
- Enter OTP within 15 minutes
- Set new password
- Login with new password
- All actions trigger notifications
- Unread count updates
- Mark as read works
- Notifications display correctly
Error: Connection failed: Access denied
Solution:
// Check includes/config.php or includes/db.php
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', ''); // ← Check this matches your MySQL password
define('DB_NAME', 'blood');Error: 404 Not Found - admin/dashboard.php
Solution: Already fixed! Login now redirects to admin/admin.php
Status: ✅ FIXED
Users with status='pending' are now blocked from logging in.
Error: You have an error in your SQL syntax
Status:
Temporary Workaround: Avoid special characters in inputs
Error: SMTP Error
Solutions:
- Check Gmail App Password in
includes/mailer.php - Enable "Less secure app access" (not recommended)
- Use Gmail App Password (recommended)
- Check firewall/antivirus blocking port 587
- Verify SMTP settings:
$mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->SMTPSecure = 'tls';
Causes:
- Database migration not run
notificationstable missing- Incorrect
user_idin session
Solutions:
- Check notifications table exists
- Verify user is logged in
- Check SQL queries in notification files
Status: ✅ Working
Automatic stock deduction implemented in hospital/requests.php
Solution: Run database migration:
ALTER TABLE requests
ADD COLUMN donor_id INT(11) DEFAULT NULL AFTER hospital_id;
ALTER TABLE requests
ADD CONSTRAINT fk_requests_donor
FOREIGN KEY (donor_id) REFERENCES users(user_id)
ON DELETE SET NULL;Location: includes/admin_auth.php (line ~35)
Change timeout:
$timeout = 30 * 60; // 30 minutes (change as needed)Status:
Only header/footer use unified theme. Remaining pages need updates.
Files:
assets/css/theme.css- Unified themeincludes/unified_header.php- New headerincludes/unified_footer.php- New footer
-
SQL Injection Vulnerabilities ⛔
- Status: 27% Fixed (8/30+ files)
- Impact: HIGH - Database compromise possible
- ETA: 2-3 hours to complete
-
No CSRF Protection ⛔
- Status: Not Implemented
- Impact: HIGH - Unauthorized actions possible
- ETA: 4-6 hours to implement
-
Inconsistent Session Management
⚠️ - Status: Partially Fixed
- Impact: MEDIUM - Security gaps
- ETA: 2-3 hours
-
Design Inconsistency 🎨
- Status: 0/45 pages using unified theme
- Impact: LOW - Visual inconsistency
- ETA: 2-3 days
-
XSS Vulnerabilities
⚠️ - Status: Partial protection
- Impact: MEDIUM - Script injection possible
- ETA: 3-4 hours
-
No Input Validation on Some Forms
⚠️ - Status: Basic validation only
- Impact: MEDIUM - Invalid data possible
- ETA: 2-3 hours
-
No Rate Limiting
- Impact: LOW - Brute force possible
- ETA: 2-3 hours
-
No Activity Logging
- Impact: LOW - Audit trail incomplete
- ETA: 1-2 hours
-
No Email Queue System
- Impact: LOW - Email delays possible
- ETA: 4-6 hours
- ✅ Fixed SQL injection in 8 critical files
- ✅ Added user status check in login
- ✅ Fixed admin login redirect
- ✅ Enhanced session security
- ✅ Added email validation
⚠️ 22+ files still need SQL injection fixes
- ✅ Complete password reset with OTP
- ✅ User-to-user blood requests
- ✅ Hospital notification system
- ✅ Blood stock management with visual dashboard
- ✅ Stock-based request validation
- ✅ Automatic stock deduction on approval
- ✅ Unified design system (theme.css)
- ✅ Unified header/footer components
- ✅ Fixed notification system
- ✅ Fixed empty status values in database
- ✅ Added donor_id field to requests table
- ✅ Fixed redirect paths
- ✅ Fixed session variable conflicts
- ✅ Added
donor_idcolumn to requests table - ✅ Added foreign key constraints
- ✅ Added performance indexes
- ✅ Fixed data integrity issues
- ✅ Consolidated SQL files
- User registration and login
- Hospital registration
- Admin panel
- Blood stock management (basic)
- Blood request system
- Blood donation system
- Basic notifications
- README.md - This file (comprehensive guide)
- backups/blood_bank_complete.sql - Complete database with sample data
- backups/sample_data_insert.sql - Additional sample data (NEW)
All issues documented below have been consolidated into this README:
- PRODUCTION_READINESS_REPORT.md - Security analysis
- SQL_INJECTION_FIX_PROGRESS.md - Fix tracking
- CHANGES_SUMMARY.md - Complete changelog
- FIXES_DOCUMENTATION.md - Technical details
- Fix all SQL injection vulnerabilities
- Implement CSRF protection
- Add XSS protection (htmlspecialchars)
- Implement rate limiting
- Add account lockout mechanism
- Enable HTTPS only
- Change all default passwords
- Remove sample data from database
- Disable error display (
display_errors = Off) - Enable error logging
- Update database credentials
- Configure email (SMTP)
- Set correct BASE_URL
- Configure session timeout
- Set up backup system
- Configure file upload limits
- Set proper file permissions
- Test all user flows
- Test all admin functions
- Test all hospital functions
- Test notification system
- Test password reset
- Test on multiple browsers
- Test on mobile devices
- Load testing
- Security audit
- Create admin user guide
- Create hospital user guide
- Create donor user guide
- Document API endpoints (if any)
- Create backup/restore guide
- Document server requirements
Developer: CERO-100
Repository: https://github.com/CERO-100/BloodBank
Support: [Create an issue on GitHub]
[Add your license information here]
- Bootstrap 5 - UI Framework
- Font Awesome 6.5.0 - Icons
- PHPMailer - Email functionality
- SweetAlert2 - Beautiful alerts
- Chart.js - Dashboard charts
For issues and questions:
- Check this README first
- Check troubleshooting section
- Review documentation files
- Check PHP error logs
- Create GitHub issue
Current Status: 27% security fixes complete (8/30+ files)
Estimated Production Ready: 5-7 days
Last Updated: November 12, 2025
Version: 2.0-dev
Status: 🔄 In Development