A full-stack PHP + MySQL web application that allows publishers to sell and distribute books online, manage competitions, and engage readers with interactive features.
- Overview
- Core Features
- System Architecture
- Folder Structure
- Database Schema
- Installation Guide
- Default Admin Credentials
- Development Workflow
- API Endpoints / Page Map
- Security & Best Practices
- Future Enhancements
- Author & License
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.
- 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.
- 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.
| 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 |
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
| Field | Type | Key | Description |
|---|---|---|---|
| user_id | INT | PK | Unique ID |
| full_name | VARCHAR(100) | Userβs full name | |
| 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 |
| Field | Type | Key | Description |
|---|---|---|---|
| admin_id | INT | PK | Unique admin ID |
| username | VARCHAR(100) | UNIQUE | Admin username |
| password | VARCHAR(255) | Hashed password |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 CASCADEfor relational integrity.
- XAMPP / Laragon / WAMP
- PHP 8.0 or higher
- MySQL 5.7 or higher
- Web browser (Chrome, Edge, etc.)
- Copy the folder to your web root (
htdocs/online_ebook_system). - Start Apache and MySQL.
- Visit
http://localhost/online_ebook_system/setup_database.php.- This automatically creates the database
online_ebook_dband all tables. - A default admin account is also created.
- This automatically creates the database
- Once βπ Setup completed successfullyβ appears, delete
setup_database.phpfor security. - Access:
- User Portal:
http://localhost/online_ebook_system/user/ - Admin Portal:
http://localhost/online_ebook_system/admin/
- User Portal:
| Field | Value |
|---|---|
| Username | admin |
| Password | admin123 |
Change immediately after first login.
- Frontend Pages β design in HTML + Bootstrap.
- PHP Controllers β process forms and queries.
- Database Layer β use
mysqliorPDOprepared statements. - Authentication β password hashing + session tokens.
- Admin Dashboard β manage data using CRUD interfaces.
| 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 |
- 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.phpafter installation. - Validate timer logic server-side for competitions.
- 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).
Project By: Zayan (Prime Creators)
Language: PHP 8 + MySQL
License: MIT β Free for educational and personal use.
βKnowledge shared is knowledge multiplied.β