A comprehensive web-based library management system built with PHP, MySQL, and Bootstrap. Designed for educational institutions to manage books, borrowers, reservations, and penalties efficiently with role-based access control.
- Features
- User Roles & Permissions
- System Requirements
- Installation
- Database Setup
- Project Structure
- Architecture & Design Patterns
- Usage Guide
- Security Features
- Technologies Used
- Business Logic
- Troubleshooting
- Contributing
- License
✅ User Authentication - Secure login/signup with password hashing (bcrypt)
✅ Role-Based Access Control - Four distinct user roles with specific permissions
✅ Book Management - Complete CRUD operations for library inventory
✅ Borrowing System - Track book checkouts and returns with due dates
✅ Reservation System - Online book reservation with approval workflow
✅ Penalty Management - Automatic calculation of late fees (₱10/day)
✅ Clearance Processing - Semester-end clearance verification
✅ Real-time Search - Instant book and borrower search functionality
🔒 Security First - SQL injection prevention, XSS protection, password hashing
🎨 Modern UI - Responsive design with custom styled components
📱 Mobile Friendly - Works seamlessly on all devices
🏗️ MVC Architecture - Clean code organization and separation of concerns
🔄 OOP Principles - Inheritance, polymorphism, and encapsulation
⚡ Optimized Performance - Efficient database queries with PDO prepared statements
- Borrowing Limit: 3 books per semester
- Clearance: Must return all books or pay book price for unreturned items
- Permissions:
- Reserve books online
- View borrowed books and due dates
- View penalties and payment status
- Check clearance status
- Borrowing Limit: Unlimited books
- Clearance: Must return all books at semester end
- Permissions:
- Reserve books online
- View borrowed books and due dates
- View penalties
- Check clearance status
- Primary Role: Book Inventory Management
- Permissions:
- Add new books to inventory
- Update book information (title, author, ISBN, category, price, copies)
- Archive books (soft delete)
- View complete book catalog
- Search and filter books
- Primary Role: Transaction Management
- Permissions:
- Process book borrowing
- Process book returns
- Add and manage penalties
- Approve/reject reservations
- Process semester clearances
- View borrower status and transaction history
- Waive or mark penalties as paid
| Component | Requirement |
|---|---|
| Web Server | Apache 2.4+ (XAMPP recommended) |
| PHP | Version 8.0 or higher |
| MySQL | Version 8.0 or higher |
| Browser | Chrome 90+, Firefox 88+, Safari 14+, Edge 90+ |
| RAM | 2GB minimum (4GB recommended) |
| Storage | 500MB free space |
- XAMPP: Version 8.0. x or higher
- PHP Extensions: PDO, MySQLi, mbstring, openssl
- Text Editor: VS Code, Sublime Text, or PHPStorm
- Screen Resolution: 1920x1080 or higher
# Clone the repository
git clone https://github.com/Coding-Sean/MyLibrary.git
# OR extract downloaded ZIP to
C:\xampp\htdocs\MyLibrary- Download XAMPP from https://www.apachefriends.org
- Install with default settings
- Start Apache and MySQL modules from XAMPP Control Panel
- Open phpMyAdmin:
http://localhost/phpmyadmin - Create a new database named MyLibrary
- Import the database schema (see Database Setup)
Edit config/database.php if needed (default settings work with XAMPP):
private $host = 'localhost';
private $db_name = 'MyLibrary';
private $username = 'root';
private $password = ''; // Default XAMPP password is emptyOpen your browser and navigate to:
http://localhost/MyLibrary
You should see the login page.
-
User - Stores user information and roles
- Fields:
user_id,name,email,password,role
- Fields:
-
Book - Library inventory
- Fields:
book_id,title,author,isbn,category,copies,price,status
- Fields:
-
BorrowTransaction - Borrowing records
- Fields:
borrow_id,user_id,book_id,borrowDate,dueDate,returnDate,status
- Fields:
-
Reservation - Book reservations
- Fields:
reserve_id,user_id,book_id,reservationDate,status
- Fields:
-
Penalty - Late fees and penalties
- Fields:
penalty_id,borrow_id,amount,status,issueDate
- Clearance - Semester clearance records
- Fields:
clearance_id,user_id,semester,status,date
- Fields:
MyLibrary/
│
├── assets/ # CSS Stylesheets
│ ├── login.css # Login page styles
│ ├── signup.css # Signup page styles
│ ├── librarian.css # Librarian dashboard styles
│ ├── staff.css # Staff dashboard styles
│ └── stud_teacher.css # Student/Teacher dashboard styles
│ └── js/ # Javascripts
│ ├── librarian-dashboard.js # Librarian Scripts
│ ├── staff-dashboard.js # Staff Scripts
│ └── student-teacher-dashboard.js # student-teacher scripts
│
├── config/ # Configuration Files
│ └── database.php # Database connection (PDO)
│
├── controller/ # Request Handlers (Controllers)
│ ├── BaseController.php # Parent controller with common methods
│ ├── LoginController.php # Authentication handler
│ ├── SignupController.php # User registration handler
│ ├── LogoutController.php # Session termination
│ ├── LibrarianController.php # Book CRUD operations
│ ├── StaffController.php # Borrowing/Return/Penalty handlers
│ ├── ReservationController.php # Reservation management
│ └── UserController.php # User-related operations
│
├── database/ # Database Scripts
│ └── db_schema.sql # Database schema and sample data
│
├── includes/ # Reusable Components
│ ├── messages.php # Custom alert/notification system
│ └── confirm_modal.php # Custom confirmation dialogs
│
├── model/ # Business Logic (Models)
│ ├── BaseModel.php # Parent model with validation & sanitization
│ ├── User.php # User authentication & management
│ ├── LibrarianModel.php # Book inventory operations
│ ├── StaffModel.php # Staff operations (borrow/return/penalty)
│ └── StudentTeacherModel.php # Student/Teacher operations
│
├── view/ # User Interfaces (Views)
│ ├── Log_In.php # Login page
│ ├── Sign_Up.php # Registration page
│ ├── Librarian_Dashboard.php # Librarian interface
│ ├── Staff_Dashboard.php # Staff interface
│ ├── Teach_Stud_Dashboard.php # Student/Teacher interface
│ └── Librarian_Functions/
│ ├── Add_Book.php # Add book form
│ └── Edit_Book.php # Edit book form
│
├── index.php # Entry point (redirects to login)
└── README.md # This file
- Model: Handles business logic and database operations
- View: Presents data to users (HTML/PHP templates)
- Controller: Processes user requests and coordinates Model-View
BaseModel. php → User.php, LibrarianModel.php, StaffModel.php
BaseController.php → LoginController.php, StaffController.php- Private database connection in models
- Protected methods for validation and sanitization
- Abstract
validate()method implemented differently in each model executeQuery()method handling various SQL operations
- Register: Click "Sign Up" and select your role
- Login: Use your registered email and password
- Browse Books: View available books in the catalog
- Reserve Book: Click "Reserve" on desired book
- Check Status: Monitor borrowed books and due dates
- View Penalties: Check any late fees or unpaid penalties
- Login: Use librarian credentials
- Add Books: Click "Add Book" and fill in details
- Edit Books: Click "Edit" on any book card
- Archive Books: Mark books as archived when needed
- Search: Use search bar to find specific books
- Login: Use staff credentials
- Process Borrowing:
- Search for borrower
- Click "Borrow" → Select book → Confirm
- Process Returns:
- Click "Return" on borrower
- Select book to return
- System auto-calculates penalties if overdue
- Approve Reservations: Review and approve pending reservations
- Process Clearance: Verify student/teacher clearance for semester
- Bcrypt Hashing:
password_hash()withPASSWORD_DEFAULT - Minimum Length: 6 characters required
- Verification:
password_verify()for login
- PDO Prepared Statements: All queries use parameterized statements
- Input Validation: Type checking with
validateInt(),validateFloat() - Input Sanitization:
htmlspecialchars()and customsanitize()method
htmlspecialchars($data, ENT_QUOTES, 'UTF-8')- Session-based authentication
- Role verification on protected pages
- Secure logout with session destruction
filter_var($email, FILTER_VALIDATE_EMAIL)| Technology | Purpose | Version |
|---|---|---|
| PHP | Backend Logic | 8.0+ |
| MySQL | Database | 8.0+ |
| PDO | Database Access Layer | Native |
| Bootstrap | UI Framework | 5.3.3 |
| JavaScript | Frontend Interactivity | ES6+ |
| HTML5 | Structure | - |
| CSS3 | Styling | - |
| Apache | Web Server | 2. 4+ |
- Object-Oriented Programming (OOP)
- PDO for database operations
- Session management
- Password hashing
- Error handling with try-catch
- Type validation
Students:
- Maximum 3 books at a time
- Cannot borrow if limit reached
- Cannot borrow with unpaid penalties
Teachers:
- Unlimited borrowing
- Cannot borrow with unpaid penalties
Due Date: 14 days from borrow date
// Automatic penalty on late return
$daysLate = (current_date - due_date) / 86400;
$penaltyAmount = $daysLate * 10; // ₱10 per dayPenalty Types:
- Late Return: ₱10 per day overdue
- Lost Book: Full book price
- Status: Unpaid, Paid, Waived
Students:
- All books returned
- All penalties paid
- Maximum 3 books borrowed per semester enforced
Teachers:
- All books returned at semester end
- All penalties paid
- User reserves available book
- Staff receives notification
- Staff approves/rejects reservation
- Upon approval, book is issued immediately
- Reservation status updated to "Approved"
Solution:
- Ensure MySQL is running in XAMPP
- Verify database name is
MyLibrary - Check credentials in
config/database.php
Solution:
- Verify files are in
C:\xampp\htdocs\MyLibrary - Check Apache is running
- Access via
http://localhost/MyLibrarynothttp://localhost
Solution:
- Clear browser cookies/cache
- Ensure
session_start()is called - Check PHP session configuration
Solution:
- Verify email is registered
- Check password (case-sensitive)
- Ensure user table has correct password hash
Solution:
- Check book status is not "Archived"
- Verify database connection
- Check if books exist in database
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
Name: Jansean Libera
Course, Year & Section: BSIS 3-B
Developer: Coding-Sean
Repository: https://github.com/Coding-Sean/MyLibrary
Email: liberajansean34@gmail.com
Version: 1.0.0
Status: ✅ Complete and Functional
Last Updated: 2025
- ✨ Full MVC implementation with OOP
- 🔐 Enterprise-level security practices
- 📱 Responsive design for all devices
- ⚡ Optimized database queries
- 🎨 Custom UI components
- 📊 Comprehensive penalty system
- 🔄 Real-time search and filtering
- 📖 Complete documentation
Built with ❤️ for Educational Institutions