A PHP/MySQL e-commerce web store for buying and downloading games across PC, PlayStation, and Xbox platforms. Built with vanilla PHP, PDO, and a custom CSS theming system.
- Features
- Tech Stack
- Folder Structure
- Setup & Installation
- File Reference
- Database
- Themes
- Notes & TODOs
- Browse games by platform (PlayStation, Xbox, PC)
- User registration, login, and session management
- Shopping cart (session-based for guests, database-backed for logged-in users)
- Wishlist with add-all-to-cart support
- Blog with category filtering and comment system
- Contact form with email delivery via PHPMailer + Mailtrap SMTP
- Downloadable game client (Astroidinator .exe)
- Switchable CSS themes (Default, Fallout: New Vegas, Star Wars)
- Easter egg system tied to active theme
| Layer | Technology |
|---|---|
| Backend | PHP (procedural) |
| Database | MySQL via PDO |
| Frontend | HTML5, CSS3, vanilla JS |
| PHPMailer + Mailtrap SMTP | |
| Styling | Custom CSS with theme switching |
GameWorld/
│
├── index.php # Homepage
├── index.html # Static HTML reference/prototype
├── database.php # Root-level DB connection (legacy)
│
├── config/
│ ├── config.php # Site constants (SITE_NAME, ADMIN_EMAIL, etc.)
│ └── database.php # PDO connection used throughout the site
│
├── functions/
│ ├── functions.php # All core business logic functions
│ └── product-display.php # Product rendering helpers
│
├── includes/
│ ├── header.php # Sitewide header (nav, session start, DB include)
│ ├── footer.php # Sitewide footer
│ └── PHPMailer-master/ # PHPMailer library for email sending
│
├── templates/
│ └── product-card.php # Reusable product card component
│
├── site_functions/ # All routable page files
│ ├── about.php
│ ├── add-blog-post.php
│ ├── blog.php
│ ├── blog-detail.php
│ ├── checkout.php
│ ├── contact.php
│ ├── download.php
│ ├── login.php
│ ├── logout.php
│ ├── product-detail.php
│ ├── products.php
│ ├── register.php
│ └── wishlist.php
│
├── css/
│ └── NewVegas.css # Main stylesheet (includes all theme variants)
│
├── js/
│ └── main.js # Frontend JS (cart counters, image gallery, etc.)
│
├── images/
│ ├── products/ # Product cover images
│ ├── background_img/ # Hero/banner images
│ └── characters/ # Easter egg character images
│
├── Astroidinator.exe/ # Source for the downloadable game client
│ └── obj/Debug/
│ └── Astroidinator_SDE2025_Jkra.exe
│
└── contact_messages.txt # Flat-file backup log of contact form submissions
-
Clone the repository into your web server's root directory:
git clone https://github.com/your-username/gameworld.git -
Create the database in phpMyAdmin or via MySQL CLI:
CREATE DATABASE gameworld CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
Import the schema (ask your instructor or team for the
.sqldump file). -
Configure the database connection in
config/database.php:$host = 'localhost'; $dbname = 'gameworld'; $username = 'root'; $password = '';
-
Configure site constants in
config/config.php:define('ADMIN_EMAIL', 'your-email@example.com'); define('SITE_NAME', 'GameWorld');
-
Set up email (optional): The contact form uses Mailtrap for development. Update the SMTP credentials in
site_functions/contact.phpwith your own Mailtrap inbox credentials, or swap in a live SMTP provider for production. -
Start your server and navigate to
http://localhost/gameworld/.
| File | Purpose |
|---|---|
index.php |
Homepage — hero banner, popular games, platform categories |
products.php |
Product listing page, filterable by platform/category |
product-detail.php |
Single product view with image gallery, add to cart/wishlist |
checkout.php |
Shopping cart with quantity editing and order summary |
wishlist.php |
User wishlist with add-all-to-cart action |
login.php |
User login form and authentication |
register.php |
New user registration |
logout.php |
Destroys session and redirects to login |
about.php |
About Us page, content pulled from database |
contact.php |
Contact form — validates, logs to file, and sends email via PHPMailer |
blog.php |
Blog listing with category sidebar filter |
blog-detail.php |
Full blog post with comments section |
add-blog-post.php |
Form to create new blog posts (currently open access — see TODOs) |
download.php |
Download page for the Astroidinator game client (.exe) |
| File | Purpose |
|---|---|
templates/product-card.php |
Reusable product card — supports clickable image/title, wishlist or remove button |
includes/header.php |
Global header: starts session, loads DB + functions, renders nav |
includes/footer.php |
Global footer with links |
| File | Purpose |
|---|---|
config/database.php |
PDO connection setup |
config/config.php |
Site-wide constants |
functions/functions.php |
All helper functions: auth, cart, wishlist, DB queries, sanitization |
functions/product-display.php |
Product formatting helpers (e.g. formatPrice()) |
The gameworld MySQL database includes the following tables (approximate):
| Table | Description |
|---|---|
products |
Game listings with name, price, images, descriptions, stock |
categories |
Platform categories (PlayStation, Xbox, PC) |
product_images |
Additional images per product |
users |
Registered user accounts (hashed passwords) |
cart |
Persistent cart items per user |
wishlist |
Wishlist items per user |
blog_posts |
Blog post content |
blog_comments |
Comments linked to blog posts |
about_sections |
Content blocks for the About Us page |
easter_eggs |
Theme-specific easter egg quotes and images per product |
The site supports three visual themes, switchable via query string:
| Theme key | Style |
|---|---|
default |
Standard dark gaming aesthetic |
newvegas |
Fallout: New Vegas — retro-futuristic amber, unlocks in-page easter eggs |
starwars |
Star Wars — space-inspired colour palette |
Switch via the header buttons or manually: ?theme=newvegas
The active theme is stored in $_SESSION['theme'] and applied as a CSS class on the <body> tag.
add-blog-post.phpis currently accessible to all users. An authentication check should be added to restrict it to admins/moderators.product-detail.phpandproducts.phpboth have a TODO to add publisher, release date, franchise, and developer fields.checkout.phphas a placeholder checkout button with a humorousalert()— real payment processing is not implemented.contact_messages.txtis written to thesite_functions/directory as a backup log. This file should be excluded from version control (add to.gitignore).- The Mailtrap SMTP credentials in
contact.phpare for development/sandbox use only. Replace before deploying to production.
contact_messages.txt
config/database.php
Astroidinator.exe/
GameWorld — SDE2025 Project