Skip to content

muhammadzayan19/EBook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Online E-Book System

A full-stack PHP + MySQL web application that allows publishers to sell and distribute books online, manage competitions, and engage readers with interactive features.


🧾 Table of Contents

  1. Overview
  2. Core Features
  3. System Architecture
  4. Folder Structure
  5. Database Schema
  6. Installation Guide
  7. Default Admin Credentials
  8. Development Workflow
  9. API Endpoints / Page Map
  10. Security & Best Practices
  11. Future Enhancements
  12. Author & License

🧩 Overview

Goal: Digitize the publisher’s workflow so customers can:

  • Register & purchase e-books directly.
  • Download PDFs instantly after payment.
  • Join essay/story competitions and upload entries.
  • View winners, prizes, and upcoming contests.

Admin Portal: Manages books, orders, payments, and competitions from one dashboard.


🎯 Core Features

πŸ‘₯ User Side

  • Registration & Login (with hashed passwords).
  • Browse books with category, author, and search filters.
  • Purchase books (PDF / CD / Hard Copy).
  • Download PDF after payment verification.
  • Join timed essay/story competitions (3-hour countdown).
  • Upload entries (.doc/.pdf).
  • View winners & competition results.

πŸ§‘β€πŸ’Ό Admin Side

  • Secure admin authentication.
  • CRUD operations on books, users, orders, competitions.
  • Upload book PDFs.
  • Track orders & payment status.
  • Manage competitions & declare winners.
  • Display notices and home-page announcements.

πŸ—οΈ System Architecture

Layer Components Description
Presentation HTML / CSS / Bootstrap / JS User interface
Application PHP controllers (user, admin) Handles logic & validation
Data Access config/db.php, includes/functions.php MySQL connection and helpers
Storage MySQL (DB: online_ebook_db) Persistent data storage
Uploads /uploads/books, /uploads/essays File storage for PDFs and entries

πŸ—‚ Folder Structure

EBOOK/
β”‚
β”œβ”€β”€ config/
β”‚   └── db.php                # Database connection
β”‚
β”œβ”€β”€ includes/
β”‚   β”œβ”€β”€ header.php            # Navigation / layout header
β”‚   β”œβ”€β”€ footer.php            # Footer template
β”‚   └── admin_header.php      # Header for Admin Pages
β”‚   └── admin_footer.php      # Footer for Admin Pages
β”‚   └── admin_sidebar.php     # Sidebar for Admin Pages
β”‚
β”œβ”€β”€ admin/
β”‚   β”œβ”€β”€ login.php             # Admin login page
β”‚   β”œβ”€β”€ index.php             # Admin dashboard
β”‚   β”œβ”€β”€ manage_books.php      # CRUD for books
β”‚   β”œβ”€β”€ manage_users.php      # View/edit users
β”‚   β”œβ”€β”€ manage_orders.php     # Manage orders & payments
β”‚   β”œβ”€β”€ manage_competitions.php # Add/edit competitions
β”‚   β”œβ”€β”€ winners.php           # Declare & view winners
β”‚   └── logout.php
β”‚
β”œβ”€β”€ user/
β”‚   β”œβ”€β”€ register.php          # User registration
β”‚   β”œβ”€β”€ login.php             # User login
β”‚   β”œβ”€β”€ profile.php           # Profile dashboard
β”‚   β”œβ”€β”€ books.php             # Browse all books
β”‚   β”œβ”€β”€ book_details.php      # Single book info
β”‚   β”œβ”€β”€ order.php             # Order placement
β”‚   β”œβ”€β”€ competition.php       # Competition landing
β”‚   β”œβ”€β”€ upload_essay.php      # Essay upload page
β”‚   β”œβ”€β”€ my_orders.php         # User Orders
β”‚   β”œβ”€β”€ my_submissions.php    # Essay Submissions
β”‚   β”œβ”€β”€ my_books.php          # User Books
β”‚   └── logout.php
β”‚
β”œβ”€β”€ uploads/
β”‚   β”œβ”€β”€ books/                # Uploaded PDF files
β”‚   └── essays/               # Uploaded user essays
β”‚   └── book_covers/          # Uploaded Book Covers
β”‚
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── images/
β”‚
β”œβ”€β”€ db_setup.php              # Auto-creates DB & tables
β”œβ”€β”€ index.php                 # Home page
β”œβ”€β”€ about.php                 # About the publisher
β”œβ”€β”€ contact.php               # Contact information
└── README.md

🧠 Database Schema

1️⃣ users

Field Type Key Description
user_id INT PK Unique ID
full_name VARCHAR(100) User’s full name
email VARCHAR(100) UNIQUE Login email
password VARCHAR(255) Hashed password
address TEXT Delivery address
phone VARCHAR(15) Contact number
registered_at DATETIME Timestamp of registration

2️⃣ admins

Field Type Key Description
admin_id INT PK Unique admin ID
username VARCHAR(100) UNIQUE Admin username
password VARCHAR(255) Hashed password

3️⃣ books

Field Type Key Description
book_id INT PK Unique ID
title VARCHAR(255) Book title
author VARCHAR(255) Book author
category VARCHAR(100) Genre/category
description TEXT Book details
price DECIMAL(10,2) Purchase price
subscription_price DECIMAL(10,2) Subscription price
type ENUM('pdf','cd','hardcopy') Book format
file_path VARCHAR(255) Path to uploaded file
image_path VARCHAR(255) Path to uploaded book image
stock INT Quantity in stock
is_free TINYINT(1) 1 if free, else 0
created_at DATETIME Created timestamp

4️⃣ orders

Field Type Key Description
order_id INT PK Unique ID
user_id INT FK Linked to users.user_id
book_id INT FK Linked to books.book_id
quantity INT Number of copies
order_type VARCHAR(20) Type of order
total_amount DECIMAL(10,2) Total cost
status ENUM('pending','paid') Order status
order_date DATETIME Timestamp

5️⃣ payments

Field Type Key Description
payment_id INT PK Unique ID
order_id INT FK Linked to orders.order_id
payment_method VARCHAR(50) e.g., card, PayPal
amount DECIMAL(10,2) Amount paid
payment_status ENUM('pending','completed') Payment state
payment_date DATETIME Timestamp

6️⃣ competitions

Field Type Key Description
comp_id INT PK Unique ID
title VARCHAR(255) Competition title
type ENUM('essay','story') Type of contest
topic TEXT Topic description
start_date DATETIME Start date
end_date DATETIME End date
prize VARCHAR(255) Reward/prize
status ENUM('active','closed') Competition status

7️⃣ submissions

Field Type Key Description
submission_id INT PK Unique ID
comp_id INT FK Linked to competitions.comp_id
user_id INT FK Linked to users.user_id
file_path VARCHAR(255) Uploaded essay path
submitted_at DATETIME Submission timestamp

8️⃣ winners

Field Type Key Description
winner_id INT PK Unique ID
comp_id INT FK Linked to competitions.comp_id
user_id INT FK Linked to users.user_id
position VARCHAR(50) e.g., 1st, 2nd, 3rd
prize VARCHAR(255) Award received
remarks VARCHAR(255) Comment on Winner
announced_at DATETIME Announcement date

🧩 Note: All foreign keys use ON DELETE CASCADE for relational integrity.


πŸš€ Installation Guide

1️⃣ Requirements

  • XAMPP / Laragon / WAMP
  • PHP 8.0 or higher
  • MySQL 5.7 or higher
  • Web browser (Chrome, Edge, etc.)

2️⃣ Setup Steps

  1. Copy the folder to your web root (htdocs/online_ebook_system).
  2. Start Apache and MySQL.
  3. Visit http://localhost/online_ebook_system/setup_database.php.
    • This automatically creates the database online_ebook_db and all tables.
    • A default admin account is also created.
  4. Once β€œπŸŽ‰ Setup completed successfully” appears, delete setup_database.php for security.
  5. Access:

πŸ”‘ Default Admin Credentials

Field Value
Username admin
Password admin123

Change immediately after first login.


🧭 Development Workflow

  1. Frontend Pages – design in HTML + Bootstrap.
  2. PHP Controllers – process forms and queries.
  3. Database Layer – use mysqli or PDO prepared statements.
  4. Authentication – password hashing + session tokens.
  5. Admin Dashboard – manage data using CRUD interfaces.

πŸ”— API Endpoints / Page Map

Page Description
/user/register.php New user registration
/user/login.php User login
/user/books.php Book listing page
/user/book_details.php?id= View specific book
/user/order.php Place book order
/user/competition.php Join competition
/user/upload_essay.php Upload entry (3 hour timer)
/admin/login.php Admin login
/admin/manage_books.php Add/Edit books
/admin/manage_competitions.php Manage competitions
/admin/winners.php Publish winners

πŸ›‘οΈ Security & Best Practices

  • Use password_hash() / password_verify() for all passwords.
  • Sanitize input via mysqli_real_escape_string() or prepared statements.
  • Restrict uploads to safe file types (PDF/DOCX).
  • Use sessions for authentication.
  • Delete setup_database.php after installation.
  • Validate timer logic server-side for competitions.

πŸ’‘ Future Enhancements

  • Payment Gateway Integration (Stripe / PayPal).
  • Book rating & review system.
  • Subscription auto-renewal.
  • Email verification & password reset.
  • REST API for mobile apps.
  • Admin analytics dashboard (Charts.js).

πŸ‘¨β€πŸ’» Author & License

Project By: Zayan (Prime Creators)
Language: PHP 8 + MySQL
License: MIT – Free for educational and personal use.

β€œKnowledge shared is knowledge multiplied.”

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages