1.
Introduction
1.1 Project Overview
The Book Shop Management System is a web-based application designed to facilitate the online
purchasing of books and gifts, allowing users to browse, search, and manage books efficiently.
The system includes authentication features, a dashboard for book management, and a section for
popular books and authors.
1.2 Objectives
• Develop an online platform for book purchasing and management.
• Implement a secure authentication system.
• Display book categories, popular books, and gift items.
• Provide an easy-to-use user interface for customers and administrators.
2. System Requirements
2.1 Hardware Requirements
• Processor: Intel Core i3 or higher
• RAM: 4GB or more
• Storage: 10GB free disk space
• Internet connection
2.2 Software Requirements
• XAMPP (Apache, PHP, MySQL)
• Web Browser (Chrome, Firefox, Edge)
• Code Editor (VS Code, Sublime Text)
• PHP 7 or later
• MySQL Database
3. System Design
3.1 Architecture
The project follows a client-server architecture, where the front-end interacts with the back-end
database through PHP scripts.
3.2 Database Design
The system utilizes a MySQL database to store user credentials, book details, author information,
and order records. Key tables include:
• users (UserID, Name, Email, Password, Role)
• books (BookID, Title, Author, Price, Category, Availability)
• orders (OrderID, UserID, BookID, Quantity, Status)
3.3 User Roles
• Admin: Manages books, orders, and users.
• Customer: Browses books, places orders, and manages profile.
4. Implementation
Technologies Used
• Front-end: HTML, CSS, JavaScript
• Back-end: PHP
• Database: MySQL
• Server: Apache (via XAMPP)
Key Points
1. Database Credentials:
o Uses "localhost", "root", and "" (empty password) for local XAMPP setup.
o The database name is "bookshop".
2. Creating a Connection:
o Uses new mysqli() to establish a connection with MySQL.
3. Error Handling:
o If the connection fails, die() stops execution and displays an error message.
4. Usage in Other Files:
o include 'config.php'; allows reuse in multiple PHP scripts.
o Example:
o include 'config.php';
o $sql = "SELECT * FROM books";
o $result = $conn->query($sql);
Explanation of BookShop.php
The BookShop.php file dynamically retrieves and displays book details from the database. It
ensures users can browse available books in the Book Shop Management System.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection.
2. Fetching Books:
o The SQL query SELECT * FROM books retrieves all books from the database.
3. Displaying Books:
o A while loop iterates through each book record and dynamically generates HTML
content.
4. Closing Connection:
conn->close(); ensures the database connection is properly closed after fetching data.
Explanation of AllBooks.php
The AllBooks.php file is responsible for retrieving and displaying information about all the books
available in the Book Shop Management System. It provides users with a view of different books,
including their titles, authors, descriptions, and prices, fetched from the database.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection.
2. Fetching Writers:
o The SQL query SELECT * FROM writers retrieves all author details from the
database.
3. Displaying Writers:
o A while loop iterates through each writer's record and dynamically generates
HTML content.
4. Closing Connection:
o conn->close(); ensures the database connection is properly closed after fetching
data.
Explanation of Writers.php
The Writers.php file retrieves and displays information about authors (writers) in the Book Shop
Management System. It ensures users can view details of different authors from the database.
Explanation of Gifts.php
The Gifts.php file retrieves and displays information about various gift items in the Gift Shop
Web Application. It allows users to view gift details from the database, such as the name,
description, and price of the gifts available for purchase.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection to ensure that the script can
interact with the database.
2. Fetching Gifts:
o The SQL query SELECT * FROM gifts retrieves all gift details from the database,
including their names, descriptions, and prices.
3. Displaying Gifts:
o A while loop is used to iterate through the fetched gift records. It dynamically
generates HTML content for each gift, displaying the name, description, and price.
4. Closing Connection:
conn->close(); ensures the database connection is properly closed after the data is fetched.
Explanation of AllBooks.php
The AllBooks.php file is responsible for retrieving and displaying information about all the books
available in the Book Shop Management System. It provides users with a view of different books,
including their titles, authors, descriptions, and prices, fetched from the database.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection to allow access to the
database and fetch book data.
2. Fetching Books:
o The SQL query SELECT * FROM books retrieves all the details of the books from
the database, including their titles, authors, descriptions, and prices.
3. Displaying Books:
o A while loop iterates through each book record returned by the query and
dynamically generates HTML content to display each book’s title, author,
description, and price.
4. Closing Connection:
o conn->close(); ensures the database connection is properly closed after the data
retrieval.
Explanation of Popular.php
The Popular.php file retrieves and displays information about the most popular books in the Book
Shop Management System. It focuses on presenting books that are highly rated or in high
demand, making it easier for users to discover popular books.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection, allowing the script to interact
with the database.
2. Fetching Popular Books:
o The SQL query SELECT * FROM books WHERE Popular = 1 fetches books from
the database that are marked as popular (assuming the Popular column is used to
identify such books).
3. Displaying Books:
o A while loop is used to iterate through each popular book record returned by the
query. It dynamically generates HTML content to display each book’s title, author,
description, and price.
4. Closing Connection:
conn->close(); ensures the database connection is properly closed after fetching the data.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection.
2. Fetching Books:
o The SQL query SELECT * FROM books retrieves all books from the database.
3. Displaying Books:
o A while loop iterates through each book record and dynamically generates HTML
content.
4. Closing Connection:
o conn->close(); ensures the database connection is properly closed after fetching
data.
Explanation of login.php
The login.php file handles the user login process in the Web App. It allows users to authenticate
by entering their username and password, then checks the entered details against the database to
grant access if the credentials are correct.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection, allowing the script to interact
with the database for authentication.
2. Handling Form Data:
o The script checks if the form was submitted via the POST method and then retrieves
the entered username and password.
3. User Authentication:
o The SQL query SELECT * FROM users WHERE username = '$username' searches
the database for a user with the matching username.
o The password_verify function is used to securely compare the entered password
with the hashed password stored in the database.
4. Session Management:
o If the login is successful, a session is started with session_start(), and the username
is stored in the session.
o The user is then redirected to the dashboard.php page using header("Location:
dashboard.php");.
5. Error Handling:
o The script provides error messages if the user is not found or if the password is
incorrect.
6. Closing Connection:
o conn->close(); ensures the database connection is properly closed after the
authentication process.
Explanation of register.php
The register.php file handles the user registration process in the Web App. It allows new users to
create an account by providing their username, email, and password. The script checks for existing
users and securely stores the new user's information in the database if everything is valid.
Key Points
1. Database Connection:
o include 'config.php'; imports the database connection, allowing the script to interact
with the database and perform the necessary operations.
2. Handling Form Data:
o The script checks if the form was submitted via the POST method and retrieves the
entered username, email, and password from the form fields.
3. Username Check:
o The SQL query SELECT * FROM users WHERE username = '$username' checks
if the username already exists in the database. If the username is already taken, an
error message is displayed.
4. Password Hashing:
o Before storing the password in the database, it is securely hashed using
password_hash($password, PASSWORD_DEFAULT) to enhance security.
5. Inserting User Data:
o The script inserts the new user's data (username, email, and hashed password) into
the users table in the database using the SQL query INSERT INTO users....
6. Redirecting:
o If the registration is successful, the user is redirected to the login.php page using
header("Location: login.php");.
7. Error Handling:
o The script provides error messages if the username is already taken or if there's an
issue with inserting the new user into the database.
8. Closing Connection:
o conn->close(); ensures the database connection is properly closed after the
registration process.
Key Points
1. Session Management:
o session_start(); initializes the session to access session variables like the username
of the logged-in user.
2. User Authentication Check:
o The script checks if the username session variable is set, redirecting to login.php if
the user is not logged in.
3. Handling Form Submission:
o When the form is submitted via POST, the script processes the input data for the
email and password fields.
o If a new password is provided, it is hashed using password_hash() before being
updated in the database.
o If no password is provided, only the email is updated.
4. Updating User Information:
o The SQL query UPDATE users SET ... updates the user's email and password (if
provided) in the database.
5. Pre-Filling the Form:
o The script fetches the current user details (SELECT * FROM users WHERE
username = '$username') to pre-fill the form with the existing email, allowing users
to modify their information.
o The script provides error messages if the update fails or if the user is not found in
the database.
Key Points
1. General Body Styling:
o The body selector sets the font to Arial and applies a light gray background color
(#f0f0f0) for the login page. It also resets margin and padding to ensure the layout
starts from scratch.
2. Login Container Styling:
o The .login-container class defines the styling for the login form's container,
including a fixed width (300px), centered positioning with margin: auto, and
padding for spacing inside the form.
o It has a white background, rounded corners (border-radius: 8px), and a subtle
shadow effect (box-shadow) for a clean and modern look.
3. Heading Styling:
o The h2 inside .login-container is centered and given a dark color (#333), with a
margin below to space it from the form fields.
4. Input Fields Styling:
o The input fields for the username and password are styled to take up the full width
of the form (width: 100%). They have padding, margin, a light border, and rounded
corners for a smooth and clean appearance.
o box-sizing: border-box; ensures that padding and border are included in the
element's total width, preventing the fields from exceeding their container.
Conclusion
The Book Shop Management System successfully provides a seamless online book-shopping
experience. The project implements essential features such as authentication, book management,
and order processing. Future enhancements may include a payment gateway, user reviews, and
an AI-based recommendation system.