James Williams
Birmingham Newman University
jwilliams@staff.newman.ac.uk
3-hour session
Project Type: Individual full-stack e-commerce application
Weighting: 100% of module grade
Technology Stack: PHP, MySQL, HTML5, CSS3, JavaScript, Bootstrap
Due: End of module (consultation with tutor required)
ecommerce-project/
├── assets/
│ ├── css/
│ ├── js/
│ └── images/
├── includes/
│ ├── config.php
│ ├── database.php
│ ├── functions.php
│ └── auth.php
├── admin/
│ ├── dashboard.php
│ ├── products.php
│ └── orders.php
├── uploads/
│ └── products/
├── index.php
├── products.php
├── cart.php
├── checkout.php
├── login.php
├── register.php
└── README.md
-- Users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
role ENUM('user', 'admin') DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Products table
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10,2) NOT NULL,
stock INT DEFAULT 0,
image VARCHAR(255),
category_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Orders table
CREATE TABLE orders (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
total DECIMAL(10,2),
status ENUM('pending', 'processing', 'shipped', 'delivered'),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
// Example: Secure password hashing
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
// Example: Prepared statement
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
// Example: Output escaping
echo htmlspecialchars($userInput, ENT_QUOTES, 'UTF-8');
/**
* User authentication function
* Validates user credentials and creates session
* @param string $email User email address
* @param string $password User password
* @return array|false User data or false on failure
* Reference: Harvard Newman Format (2024)
*/
function authenticateUser($email, $password) {
// Implementation here
}
Use this time to work on your project thoroughly and get guidance from your tutor
// Useful PHP functions for e-commerce
session_start(); // Session management
password_hash(); // Password hashing
password_verify(); // Password verification
htmlspecialchars(); // Output escaping
filter_var(); // Input validation
PDO::prepare(); // Prepared statements
move_uploaded_file(); // File uploads
// Example: Proper error handling
try {
$stmt = $pdo->prepare("INSERT INTO products (name, price) VALUES (?, ?)");
$stmt->execute([$name, $price]);
echo "Product added successfully";
} catch(PDOException $e) {
error_log("Database error: " . $e->getMessage());
echo "An error occurred. Please try again.";
}
Focus on building a solid foundation for your e-commerce application
README.md should include:
- Project overview and features
- Technology stack used
- Installation instructions
- Database setup guide
- References and resources used
Use this time for:
Don't hesitate to ask questions and seek guidance!
Recommended Timeline:
Week 1: Foundation and basic features
Week 2: Core e-commerce functionality
Week 3: Advanced features and security
Week 4: Testing, documentation, and final review
Remember: Start early and test frequently!