Skip to content

pamod-madubashana/BookHaven

Repository files navigation

📚 BookHaven Library

BookHaven Library Icon

Your gateway to knowledge, imagination, and endless possibilities

A comprehensive library management system built with HTML, CSS, JavaScript, PHP, and MySQL. The system allows users to browse, search, and reserve books, request new books, and manage their reservations. Administrators can manage books, reservations, and book requests.

Features

Public Pages

  • Home page with featured books and search
  • Books catalog with advanced filtering
  • Book detail pages with reservation functionality
  • Services page with membership inquiry form
  • About page with library information
  • Contact form with message storage
  • Book request system for unavailable books
  • FAQ and Policies pages

User Features

  • User registration and authentication
  • Book reservation ("Mark as Mine") functionality
  • Ability to cancel reservations
  • View current and past reservations
  • Request books not in the library

Admin Features

  • Dashboard with statistics
  • Full CRUD operations for books
  • Manage reservations (view, reject with reason)
  • Manage book requests (approve/reject with reasons)
  • Option to add approved requests as new books

Technical Requirements

  • Web Server (Apache/Nginx)
  • PHP 7.4 or higher
  • MySQL 5.7 or higher
  • Modern web browser

Setup Instructions

1. Database Setup

  1. Create a new MySQL database named bookhaven
  2. Import the database.sql file to create tables and insert sample data:
    mysql -u root -p < database.sql

2. Configuration

  1. Update the database credentials in includes/db.php if needed:
    define('DB_HOST', 'localhost');      // Your database host
    define('DB_NAME', 'bookhaven');     // Your database name
    define('DB_USER', 'root');          // Your database username
    define('DB_PASS', '');              // Your database password

3. File Structure

Ensure the following directory structure exists:

/library-app/
  /assets/
    /css/style.css
    /js/app.js
  /includes/
    db.php
    auth.php
    header.php
    footer.php
    functions.php
  /admin/
    index.php
    books.php
    reservations.php
    requests.php
  index.php
  books.php
  book.php
  services.php
  about.php
  contact.php
  request.php
  my_reservations.php
  login.php
  register.php
  logout.php
  database.sql
  README.md

4. Web Server Configuration

Place the application files in your web server's document root (e.g., htdocs for XAMPP, www for WAMP).

5. Default Admin Login

After setup, you can log in to the admin panel using:

  • Email: admin@library.com
  • Password: password123

Database Schema

The system uses the following tables:

  • users: Stores user information (name, email, password, role)
  • books: Stores book information (title, author, category, ISBN, etc.)
  • reservations: Tracks book reservations (user, book, status, etc.)
  • book_requests: Manages user requests for new books
  • contact_messages: Stores messages from the contact form
  • membership_inquiries: Stores membership inquiry forms

Business Logic

Availability Calculation

  • Available copies = Total copies - Active reservations
  • Reservation buttons are disabled when no copies are available
  • Users cannot reserve the same book twice while it's active

Reservation Statuses

  • ACTIVE: Currently reserved
  • CANCELLED: User cancelled
  • REJECTED: Admin rejected

Book Request Statuses

  • PENDING: Awaiting admin review
  • APPROVED: Approved by admin
  • REJECTED: Rejected by admin

Security Features

  • Prepared statements to prevent SQL injection
  • Password hashing with PHP's password_hash()
  • Session-based authentication
  • Input validation and sanitization
  • Role-based access control

File Organization

Includes

  • db.php: Database connection
  • auth.php: Authentication functions
  • functions.php: Utility functions
  • header.php: Common header template
  • footer.php: Common footer template

Assets

  • assets/css/style.css: All styling
  • assets/js/app.js: JavaScript functionality
  • assets/images/icon.png: Main application icon (192x192 pixels)
  • assets/images/favicon-16x16.png: 16x16 favicon
  • assets/images/favicon-32x32.png: 32x32 favicon
  • assets/images/apple-touch-icon.png: 180x180 Apple touch icon
  • assets/images/site.webmanifest: Web app manifest for PWA support

Customization

Styling

Modify assets/css/style.css to customize the appearance of the application.

Functionality

Add new features by extending the existing PHP functions in includes/functions.php.

Troubleshooting

Common Issues

  1. Database Connection Error: Verify database credentials in includes/db.php
  2. Permission Issues: Ensure web server has read/write access to necessary directories
  3. Page Not Found: Check that the file structure matches the expected organization

Debugging Tips

  • Enable PHP error reporting during development
  • Check MySQL error logs for database-related issues
  • Verify that all required PHP extensions are installed

Contributing

This system was built as a demonstration of full-stack development using core web technologies without frameworks. Contributions should maintain the simplicity and educational value of the codebase.

License

This project is created for educational purposes and can be used freely for learning and development.

About

A comprehensive library management system built with HTML, CSS, JavaScript, PHP, and MySQL. The system allows users to browse, search, and reserve books, request new books, and manage their reservations. Administrators can manage books, reservations, and book requests.

Topics

Resources

License

Stars

Watchers

Forks

Contributors