A self-hosted, web-based library management system built with PHP and MySQL. Manage your collection, control access by role, and expose a public catalog — all from a single lightweight install.
- Role-based access control — three roles:
admin,employee, anduser - Book catalog — add, edit, delete, and search items with full metadata (title, author, ISBN, type, category, publisher, year, language, pages, edition, volume, location, cover URL, status)
- Item types — Book, Magazine, Newspaper, Manuscript, Journal, Letter, Other
- Public catalog — a read-only, unauthenticated view (
catalog_public.php) with filtering, sorting, and pagination - CSV import — bulk-import books from CSV with auto-creation of missing categories and publishers; downloadable template included
- Online CSV editor — edit CSV data directly in the browser before importing
- Categories & publishers management — admin-only CRUD for categories and publishers
- User management — admin-only: create, activate/deactivate, change roles, reset passwords, delete users
- Internal messaging — employees can send messages to each other and to admins; used also for permission requests
- Permission requests — employees can request edit/delete access on books they did not create
- Audit log — every significant action (login, logout, create, edit, delete, CSV import, role change, etc.) is recorded with user, action, target, and timestamp
- Reports & statistics — charts for item type distribution, categories, languages, yearly breakdown, and monthly additions (Chart.js)
- Dashboard — summary cards and charts giving an at-a-glance overview of the collection
- Profile page — any logged-in user can change their own password
- Help & FAQ — built-in help page for staff
- One-file installer —
install.phpcreates the full database schema and seeds default data;removit/install.phpdrops and recreates everything for a clean reinstall
| Layer | Technology |
|---|---|
| Backend | PHP (PDO, prepared statements) |
| Database | MySQL / MariaDB (utf8mb4) |
| Frontend | HTML, CSS, Bootstrap Icons |
| Charts | Chart.js |
| Dev server | XAMPP (or any Apache + PHP + MySQL stack) |
- CSRF protection on every POST form (
csrfToken()/verifyCsrf()) - Passwords hashed with
password_hash()(bcrypt) - Login rate limiting — 5 failed attempts trigger a 15-minute lockout (session-based, no extra table needed)
- Session hardening —
httponly,samesite=Lax,use_strict_mode(uncommentcookie_securefor HTTPS) cover_urlsanitisation — onlyhttp://andhttps://URLs accepted;javascript:anddata:schemes are rejected- Role checks on every page —
requireAdmin()/requireEmployee()/requireLogin() - Authorization check on edit/delete — employees can only modify records they created
- All user input goes through prepared statements — no raw query interpolation
- PHP 8.0+
- MySQL 5.7+ / MariaDB 10.3+
- Apache (mod_rewrite not required)
-
Clone or download this repository into your web root (e.g.
htdocs/e-library/). -
Edit
config.phpwith your database credentials:define('DB_HOST', 'localhost'); define('DB_USER', 'your_db_user'); define('DB_PASS', 'your_db_password'); define('DB_NAME', 'your_db_name'); define('TABLE_PREFIX', 'lib_');
-
Run the installer by visiting
install.phpin your browser:http://localhost/e-library/install.phpThis creates all tables and inserts seed data (3 categories, 3 publishers, 5 sample books).
-
Delete
install.phpimmediately after a successful install. Leaving it on the server allows anyone to wipe and recreate the database. -
Log in at
index.phpwith the default credentials:Username Password Role admingplmsadm123Admin employeegplmslib123Employee Change these passwords immediately after first login.
If you need to drop everything and start fresh, run removit/install.php instead. Delete it afterwards as well.
| Table | Description |
|---|---|
{prefix}users |
User accounts with role and active flag |
{prefix}books |
The main collection; all item types stored here |
{prefix}categories |
Book categories (FK from books) |
{prefix}publishers |
Publishers (FK from books) |
{prefix}messages |
Internal messaging between users |
{prefix}audit_log |
Immutable action log |
Foreign key behaviour:
- Deleting a category or publisher sets
category_id/publisher_idtoNULLon linked books (no data loss). - Deleting a user cascades to their received messages but sets
from_usertoNULLon sent messages.
This project is released under the MIT License. See LICENSE for details.
Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request.
If you discover a security vulnerability, please follow the responsible disclosure process described in SECURITY.md.
