Skip to content

frankbwire/library-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LibraryMS β€” Library Management System

Version 1.0.0 | Built with PHP + MySQL + Bootstrap 5


πŸ“‹ Overview

A fully functional web-based Library Management System to replace Excel-based workflows. Manages books inventory, borrowers, borrowing/return transactions, and analytics.


πŸ–₯️ Requirements

  • XAMPP (Windows) or LAMP/MAMP (Linux/Mac)
  • PHP 8.0+
  • MySQL 5.7+ / MariaDB 10.3+
  • Web browser (Chrome, Firefox, Edge)

πŸš€ Setup Instructions

Step 1 β€” Copy Files

Copy the `library-system/` folder to your web server root:
  - XAMPP (Windows): C:\xampp\htdocs\library-system\
  - LAMP (Linux):    /var/www/html/library-system/
  - MAMP (Mac):      /Applications/MAMP/htdocs/library-system/

Step 2 β€” Create Database

  1. Open phpMyAdmin: http://localhost/phpmyadmin
  2. Click "New" to create a database (or let the SQL script do it)
  3. Click "Import" tab
  4. Choose database.sql from the project root
  5. Click "Go"

OR via MySQL CLI:

mysql -u root -p < database.sql

Step 3 β€” Configure Database Connection

Edit config/database.php:

define('DB_HOST', 'localhost');   // Usually 'localhost'
define('DB_USER', 'root');        // Your MySQL username
define('DB_PASS', '');            // Your MySQL password (empty for XAMPP default)
define('DB_NAME', 'library_db');  // Database name

Step 4 β€” Set Base URL

Edit config/app.php:

define('BASE_URL', 'http://localhost/library-system');

Change this if your setup uses a different port or path.

Step 5 β€” Access the System

Open your browser and go to:

http://localhost/library-system

Step 6 β€” Login

Username: admin
Password: Library@2024

⚠️ Change the default password immediately after first login.


πŸ“ Project Structure

library-system/
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ app.php              # App settings (BASE_URL, timezone, session)
β”‚   └── database.php         # Database connection (PDO)
β”œβ”€β”€ includes/
β”‚   β”œβ”€β”€ header.php           # HTML head + CSS links
β”‚   β”œβ”€β”€ sidebar.php          # Navigation sidebar
β”‚   β”œβ”€β”€ footer.php           # JS scripts
β”‚   └── helpers.php          # Utility functions (sanitize, badge, paginate, etc.)
β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ login.php            # Login page
β”‚   β”œβ”€β”€ logout.php           # Logout handler
β”‚   └── hash.php             # Password hash generator utility
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ books/
β”‚   β”‚   β”œβ”€β”€ index.php        # Books list (search, filter, paginate, delete)
β”‚   β”‚   β”œβ”€β”€ add.php          # Add new book
β”‚   β”‚   └── edit.php         # Edit book
β”‚   β”œβ”€β”€ borrowers/
β”‚   β”‚   β”œβ”€β”€ index.php        # Borrowers list
β”‚   β”‚   β”œβ”€β”€ add.php          # Add borrower
β”‚   β”‚   β”œβ”€β”€ edit.php         # Edit borrower
β”‚   β”‚   └── history.php      # Borrower borrow history
β”‚   β”œβ”€β”€ borrow/
β”‚   β”‚   β”œβ”€β”€ index.php        # All borrow records (filter, export, paginate)
β”‚   β”‚   β”œβ”€β”€ issue.php        # Issue (borrow) a book
β”‚   β”‚   └── return.php       # Return a book
β”‚   └── reports/
β”‚       β”œβ”€β”€ index.php        # Reports dashboard (5 report types)
β”‚       └── export.php       # CSV export handler
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ css/style.css        # Custom CSS (sidebar, cards, tables, print)
β”‚   └── js/app.js            # DataTables init, sidebar toggle, confirm dialogs
β”œβ”€β”€ database.sql             # Full database schema + sample data
β”œβ”€β”€ index.php                # Entry point (redirects to dashboard or login)
└── dashboard.php            # Main dashboard with stats + Chart.js charts

πŸ” Security Features

  • Password hashing: PHP password_hash() with bcrypt
  • SQL injection prevention: PDO prepared statements throughout
  • XSS prevention: htmlspecialchars() on all output
  • Session-based auth: All pages require valid session
  • Input validation: Server-side validation on all forms
  • Audit logging: All create/update/delete/borrow/return actions logged

πŸ“Š Features Summary

Books Module

  • Add, edit, delete books
  • Search by title, author, Book ID
  • Filter by category and status
  • CSV export + print
  • Auto-generate suggested Book IDs

Borrowers Module

  • Add, edit, delete borrowers
  • View full borrow history per borrower
  • Category-based ID suggestions (STU-, TCH-, STF-)
  • Filter by category and status

Borrow & Return

  • Issue books (only Available books can be borrowed)
  • Automatic book status update on borrow/return
  • Overdue detection (> 14 days, configurable via BORROW_DAYS)
  • Due date auto-calculated on issue form

Dashboard

  • 7 live stat cards
  • Bar chart: Borrow trend (last 6 months)
  • Doughnut chart: Books by category
  • Top 10 borrowed books table
  • Overdue books alert list
  • Recent transactions

Reports (5 types)

  1. Borrow Records β€” filterable by date, book category, borrower category, status
  2. All Books β€” inventory report with filters
  3. Overdue Books β€” all unreturned books past due date
  4. Most Borrowed Books β€” popularity ranking
  5. Most Active Borrowers β€” borrower activity ranking

Export

  • CSV export with UTF-8 BOM (opens correctly in Excel)
  • Print-optimized layout (hides navigation/buttons)

βš™οΈ Configuration

Change Loan Period

In config/app.php:

define('BORROW_DAYS', 14); // Change to any number

Add New Admin User

  1. Visit http://localhost/library-system/auth/hash.php?p=YourNewPassword
  2. Copy the hash
  3. Insert into users table via phpMyAdmin:
INSERT INTO users (username, password, full_name, role)
VALUES ('newadmin', 'PASTE_HASH_HERE', 'New Admin', 'admin');
  1. Delete auth/hash.php when done.

πŸ› Troubleshooting

Problem Solution
Blank page / errors Enable PHP error display: add ini_set('display_errors', 1); to config/app.php
"DB connection failed" Check config/database.php credentials
Login fails Regenerate hash using auth/hash.php and update DB
CSS not loading Check BASE_URL in config/app.php
Session not persisting Ensure PHP sessions are enabled and writable

πŸ”§ Extending the System

Add Email Notifications for Overdue

Install PHPMailer via Composer and create modules/notifications/send_overdue.php

Add Barcode Scanning

Replace text inputs with a barcode scanner input β€” most USB scanners act as keyboard input followed by Enter, which works natively with the current form design.

Add Role-Based Access

The users table already has a role column (admin/librarian). Use isAdmin() helper (already defined in helpers.php) to restrict pages.


πŸ“ License

Free to use for educational and institutional purposes.

About

A Library Management System that handles Book Records, Borrowers, Quantity and anything your Library might need.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors