This commit is contained in:
Flatlogic Bot 2025-09-10 20:32:30 +00:00
parent 4f315a1edf
commit 8d45670c2f
13 changed files with 860 additions and 126 deletions

46
admin/delete_product.php Normal file
View File

@ -0,0 +1,46 @@
<?php
session_start();
require_once __DIR__ . '/../db/config.php';
// If user is not logged in or not a super_admin, redirect to login page
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'super_admin') {
header('Location: ../login.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$product_id = $_POST['product_id'] ?? null;
if ($product_id) {
$pdo = db();
// First, check the stock quantity
$stmt = $pdo->prepare("SELECT stock_quantity FROM products WHERE id = ?");
$stmt->execute([$product_id]);
$product = $stmt->fetch(PDO::FETCH_ASSOC);
if ($product) {
if ((int)$product['stock_quantity'] === 0) {
// Stock is 0, so it's safe to delete
$delete_stmt = $pdo->prepare("DELETE FROM products WHERE id = ?");
if ($delete_stmt->execute([$product_id])) {
$_SESSION['success_message'] = 'Product deleted successfully.';
} else {
$_SESSION['error_message'] = 'Failed to delete product.';
}
} else {
// Stock is not 0, prevent deletion
$_SESSION['error_message'] = 'Cannot delete product because it is not out of stock.';
}
} else {
$_SESSION['error_message'] = 'Product not found.';
}
} else {
$_SESSION['error_message'] = 'Invalid product ID.';
}
} else {
$_SESSION['error_message'] = 'Invalid request method.';
}
header('Location: index.php');
exit;

98
admin/edit_product.php Normal file
View File

@ -0,0 +1,98 @@
<?php
session_start();
require_once __DIR__ . '/../db/config.php';
// If user is not logged in or not a super_admin, redirect to login page
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'super_admin') {
header('Location: ../login.php');
exit;
}
$product = [
'id' => '',
'name' => '',
'description' => '',
'price' => '',
'stock_quantity' => '',
'image_url' => ''
];
$pageTitle = 'Add New Product';
if (isset($_GET['id'])) {
$pageTitle = 'Edit Product';
$pdo = db();
$stmt = $pdo->prepare('SELECT * FROM products WHERE id = ?');
$stmt->execute([$_GET['id']]);
$product = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$product) {
$_SESSION['error_message'] = 'Product not found.';
header('Location: index.php');
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $pageTitle; ?> - GiftShop Admin</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="index.php">GiftShop Admin</a>
</div>
</nav>
<div class="container mt-4">
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1><?php echo $pageTitle; ?></h1>
<a href="index.php" class="btn btn-secondary">Back to Products</a>
</div>
<div class="card">
<div class="card-body">
<form action="save_product.php" method="POST">
<?php if ($product['id']): ?>
<input type="hidden" name="id" value="<?php echo $product['id']; ?>">
<?php endif; ?>
<div class="mb-3">
<label for="name" class="form-label">Product Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($product['name']); ?>" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="3"><?php echo htmlspecialchars($product['description']); ?></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="price" class="form-label">Price</label>
<input type="number" class="form-control" id="price" name="price" step="0.01" value="<?php echo htmlspecialchars($product['price']); ?>" required>
</div>
<div class="col-md-6 mb-3">
<label for="stock_quantity" class="form-label">Stock Quantity</label>
<input type="number" class="form-control" id="stock_quantity" name="stock_quantity" value="<?php echo htmlspecialchars($product['stock_quantity']); ?>" required>
</div>
</div>
<div class="mb-3">
<label for="image_url" class="form-label">Image URL</label>
<input type="text" class="form-control" id="image_url" name="image_url" value="<?php echo htmlspecialchars($product['image_url']); ?>">
</div>
<button type="submit" class="btn btn-primary">Save Product</button>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

105
admin/index.php Normal file
View File

@ -0,0 +1,105 @@
<?php
session_start();
require_once __DIR__ . '/../db/config.php';
// If user is not logged in or not a super_admin, redirect to login page
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'super_admin') {
header('Location: ../login.php');
exit;
}
// Fetch all products
$pdo = db();
$stmt = $pdo->query('SELECT * FROM products ORDER BY created_at DESC');
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard - GiftShop</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">GiftShop Admin</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="logout.php">Logout</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Product Management</h1>
<a href="edit_product.php" class="btn btn-primary">
<i class="bi bi-plus-lg"></i> Add New Product
</a>
</div>
<?php if (isset($_SESSION['success_message'])): ?>
<div class="alert alert-success">
<?php echo $_SESSION['success_message']; unset($_SESSION['success_message']); ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['error_message'])): ?>
<div class="alert alert-danger">
<?php echo $_SESSION['error_message']; unset($_SESSION['error_message']); ?>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>Stock</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($products)): ?>
<tr>
<td colspan="4" class="text-center">No products found.</td>
</tr>
<?php else: ?>
<?php foreach ($products as $product): ?>
<tr>
<td><?php echo htmlspecialchars($product['name']); ?></td>
<td>$<?php echo htmlspecialchars($product['price']); ?></td>
<td><?php echo htmlspecialchars($product['stock_quantity']); ?></td>
<td class="text-end">
<a href="edit_product.php?id=<?php echo $product['id']; ?>" class="btn btn-sm btn-outline-primary">
<i class="bi bi-pencil"></i> Edit
</a>
<form action="delete_product.php" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this product?');">
<input type="hidden" name="product_id" value="<?php echo $product['id']; ?>">
<button type="submit" class="btn btn-sm btn-outline-danger" <?php if ($product['stock_quantity'] > 0) echo 'disabled'; ?>>
<i class="bi bi-trash"></i> Delete
</button>
</form>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

6
admin/logout.php Normal file
View File

@ -0,0 +1,6 @@
<?php
session_start();
session_unset();
session_destroy();
header('Location: ../login.php');
exit;

52
admin/save_product.php Normal file
View File

@ -0,0 +1,52 @@
<?php
session_start();
require_once __DIR__ . '/../db/config.php';
// If user is not logged in or not a super_admin, redirect to login page
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'super_admin') {
header('Location: ../login.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name'] ?? '');
$description = trim($_POST['description'] ?? '');
$price = filter_var($_POST['price'], FILTER_VALIDATE_FLOAT);
$stock_quantity = filter_var($_POST['stock_quantity'], FILTER_VALIDATE_INT);
$image_url = trim($_POST['image_url'] ?? '');
$id = $_POST['id'] ?? null;
// Basic validation
if (empty($name) || $price === false || $stock_quantity === false) {
$_SESSION['error_message'] = 'Please fill in all required fields correctly.';
header('Location: ' . ($_SERVER['HTTP_REFERER'] ?? 'index.php'));
exit;
}
$pdo = db();
try {
if ($id) {
// Update existing product
$sql = "UPDATE products SET name = ?, description = ?, price = ?, stock_quantity = ?, image_url = ? WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$name, $description, $price, $stock_quantity, $image_url, $id]);
$_SESSION['success_message'] = 'Product updated successfully.';
} else {
// Insert new product
$sql = "INSERT INTO products (name, description, price, stock_quantity, image_url) VALUES (?, ?, ?, ?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$name, $description, $price, $stock_quantity, $image_url]);
$_SESSION['success_message'] = 'Product added successfully.';
}
} catch (PDOException $e) {
// In a real app, you would log this error, not show it to the user
$_SESSION['error_message'] = 'Database error. Could not save product.';
}
} else {
$_SESSION['error_message'] = 'Invalid request method.';
}
header('Location: index.php');
exit;

110
assets/css/custom.css Normal file
View File

@ -0,0 +1,110 @@
/* assets/css/custom.css */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&family=Lato:wght@400;700&display=swap');
:root {
--primary-color: #DF7E6B;
--secondary-color: #F6C390;
--background-color: #FCF8F3;
--surface-color: #FFFFFF;
--text-color: #333333;
--border-radius: 0.5rem;
}
body {
font-family: 'Lato', sans-serif;
background-color: var(--background-color);
color: var(--text-color);
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
font-family: 'Poppins', sans-serif;
font-weight: 600;
}
.btn-primary {
background-color: var(--primary-color);
border-color: var(--primary-color);
border-radius: var(--border-radius);
padding: 0.75rem 1.5rem;
transition: all 0.3s ease;
}
.btn-primary:hover {
opacity: 0.9;
transform: translateY(-2px);
}
.btn-secondary {
background-color: transparent;
border-color: var(--primary-color);
color: var(--primary-color);
border-radius: var(--border-radius);
padding: 0.75rem 1.5rem;
transition: all 0.3s ease;
}
.btn-secondary:hover {
background-color: var(--primary-color);
color: var(--surface-color);
}
.navbar {
transition: padding 0.3s ease-in-out, background-color 0.3s ease-in-out;
}
.navbar.scrolled {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
background-color: rgba(255, 255, 255, 0.95);
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.navbar-brand {
font-family: 'Poppins', sans-serif;
font-weight: 700;
color: var(--primary-color) !important;
}
.hero {
padding: 6rem 0;
background-image: linear-gradient(135deg, rgba(246, 195, 144, 0.8), rgba(223, 126, 107, 0.8)), url('https://picsum.photos/seed/giftshop-hero/1600/900');
background-size: cover;
background-position: center;
color: white;
}
.hero h1 {
font-size: 3.5rem;
font-weight: 700;
}
.section-icon {
font-size: 3rem;
color: var(--primary-color);
}
.card {
border: none;
border-radius: var(--border-radius);
box-shadow: 0 4px 15px rgba(0,0,0,0.07);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.testimonial-card .avatar {
width: 80px;
height: 80px;
border-radius: 50%;
object-fit: cover;
margin-top: -40px;
border: 4px solid var(--surface-color);
}
footer {
background-color: var(--surface-color);
}

64
assets/js/main.js Normal file
View File

@ -0,0 +1,64 @@
document.addEventListener('DOMContentLoaded', function () {
const navbar = document.querySelector('.navbar');
const contactForm = document.querySelector('#contactForm');
// Navbar shrink on scroll
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if(targetElement){
targetElement.scrollIntoView({ behavior: 'smooth' });
}
});
});
// Basic form validation
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
let isValid = true;
const name = document.getElementById('name');
const email = document.getElementById('email');
const message = document.getElementById('message');
// Reset validation
[name, email, message].forEach(el => {
el.classList.remove('is-invalid');
});
if (name.value.trim() === '') {
name.classList.add('is-invalid');
isValid = false;
}
if (!/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(email.value)) {
email.classList.add('is-invalid');
isValid = false;
}
if (message.value.trim() === '') {
message.classList.add('is-invalid');
isValid = false;
}
if (isValid) {
// On a real site, you'd send this data to the server.
// For this demo, we'll just show a success message.
document.querySelector('#form-feedback').innerHTML = '<div class="alert alert-success">Thank you for your message! We will get back to you shortly.</div>';
contactForm.reset();
} else {
document.querySelector('#form-feedback').innerHTML = '';
}
});
}
});

43
db/migrate.php Normal file
View File

@ -0,0 +1,43 @@
<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Create migrations table if it doesn't exist
$pdo->exec('CREATE TABLE IF NOT EXISTS migrations (id INT AUTO_INCREMENT PRIMARY KEY, migration VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)');
// Get all executed migrations
$stmt = $pdo->query('SELECT migration FROM migrations');
$executedMigrations = $stmt ? $stmt->fetchAll(PDO::FETCH_COLUMN) : [];
// Find all migration files
$migrationFiles = glob(__DIR__ . '/migrations/*.sql') ?: [];
sort($migrationFiles);
$migrationsRun = false;
// Run pending migrations
foreach ($migrationFiles as $migrationFile) {
$migrationName = basename($migrationFile);
if (!in_array($migrationName, $executedMigrations)) {
$sql = file_get_contents($migrationFile);
if (!empty(trim($sql))) {
$pdo->exec($sql);
// Log the migration
$stmt = $pdo->prepare('INSERT INTO migrations (migration) VALUES (?)');
$stmt->execute([$migrationName]);
echo "Migration from $migrationName ran successfully.\n";
$migrationsRun = true;
}
}
}
if (!$migrationsRun) {
echo "All migrations are up to date.\n";
}
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}

View File

@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role VARCHAR(50) NOT NULL DEFAULT 'admin',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View File

@ -0,0 +1,10 @@
CREATE TABLE IF NOT EXISTS products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10, 2) NOT NULL,
stock_quantity INT NOT NULL DEFAULT 0,
image_url VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

29
db/seed.php Normal file
View File

@ -0,0 +1,29 @@
<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Add a default admin user if one doesn't exist
$stmt = $pdo->prepare("SELECT id FROM users WHERE username = 'admin'");
$stmt->execute();
if ($stmt->fetch()) {
echo "Admin user already exists.\n";
} else {
$username = 'admin';
$password = 'password'; // You should change this!
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$role = 'super_admin';
$stmt = $pdo->prepare("INSERT INTO users (username, password, role) VALUES (:username, :password, :role)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':password', $hashed_password);
$stmt->bindParam(':role', $role);
$stmt->execute();
echo "Default admin user created with username 'admin' and password 'password'.\n";
}
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}

321
index.php
View File

@ -1,131 +1,202 @@
<?php <!DOCTYPE html>
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Style</title> <title>GiftShop - Gifts for Every Occasion</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <!-- Bootstrap CSS -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<style> <!-- Bootstrap Icons -->
:root { <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc; <!-- Google Fonts & Custom CSS -->
--text-color: #ffffff; <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head> </head>
<body> <body>
<main>
<div class="card"> <!-- Navbar -->
<h1>Analyzing your requirements and generating your website…</h1> <nav class="navbar navbar-expand-lg navbar-light bg-transparent fixed-top">
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <div class="container">
<span class="sr-only">Loading…</span> <a class="navbar-brand" href="#">GiftShop</a>
</div> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<p class="hint">Flatlogic AI is collecting your requirements and applying the first changes.</p> <span class="navbar-toggler-icon"></span>
<p class="hint">This page will update automatically as the plan is implemented.</p> </button>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p> <div class="collapse navbar-collapse" id="navbarNav">
</div> <ul class="navbar-nav ms-auto">
</main> <li class="nav-item"><a class="nav-link" href="#products">Products</a></li>
<footer> <li class="nav-item"><a class="nav-link" href="#about">About</a></li>
Page updated: <?= htmlspecialchars($now) ?> (UTC) <li class="nav-item"><a class="nav-link" href="#contact">Contact</a></li>
</footer> </ul>
<a href="#products" class="btn btn-primary ms-lg-3">Browse Catalog</a>
</div>
</div>
</nav>
<!-- Hero Section -->
<header id="home" class="hero text-center text-white">
<div class="container">
<h1 class="display-4">Gifts for Every Occasion.</h1>
<p class="lead my-4">Discover unique flowers, candies, books, and more. Perfectly packaged and delivered with care.</p>
<a href="#products" class="btn btn-primary btn-lg">Browse Catalog</a>
<a href="#contact" class="btn btn-secondary btn-lg ms-2">Contact Us</a>
</div>
</header>
<!-- Features Section -->
<section id="features" class="py-5">
<div class="container text-center">
<div class="row">
<div class="col-md-4 mb-4">
<i class="bi bi-gift section-icon mb-3"></i>
<h3>Wide Variety</h3>
<p>From fresh flowers to unique home goods, find the perfect present for anyone.</p>
</div>
<div class="col-md-4 mb-4">
<i class="bi bi-box-seam section-icon mb-3"></i>
<h3>Custom Packaging</h3>
<p>Make your gift extra special with our beautiful and creative packaging options.</p>
</div>
<div class="col-md-4 mb-4">
<i class="bi bi-truck section-icon mb-3"></i>
<h3>Fast Delivery</h3>
<p>We ensure your gifts are delivered quickly and with the utmost care across Poland.</p>
</div>
</div>
</div>
</section>
<!-- Products/Categories Section -->
<section id="products" class="py-5 bg-light">
<div class="container">
<div class="text-center mb-5">
<h2>Our Presents</h2>
<p class="lead">A glimpse into our curated collection.</p>
</div>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card h-100">
<img src="https://picsum.photos/seed/flowers/600/400" class="card-img-top" alt="A vibrant bouquet of fresh flowers.">
<div class="card-body text-center">
<h5 class="card-title">Flowers</h5>
<p class="card-text">Stunning bouquets for any celebration.</p>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<img src="https://picsum.photos/seed/candies/600/400" class="card-img-top" alt="An assortment of colorful, artisanal candies.">
<div class="card-body text-center">
<h5 class="card-title">Candies & Sweets</h5>
<p class="card-text">Delicious treats to sweeten their day.</p>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<img src="https://picsum.photos/seed/books/600/400" class="card-img-top" alt="A stack of books tied with a ribbon.">
<div class="card-body text-center">
<h5 class="card-title">Books & Stationery</h5>
<p class="card-text">Inspiring reads and beautiful paper goods.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Testimonials Section -->
<section id="about" class="py-5">
<div class="container">
<div class="text-center mb-5">
<h2>What Our Customers Say</h2>
</div>
<div class="row">
<div class="col-md-4 mb-5">
<div class="card testimonial-card text-center p-4">
<img src="https://picsum.photos/seed/avatar1/96/96" class="avatar mx-auto" alt="Customer avatar">
<div class="card-body">
<p class="card-text fst-italic">"The most beautiful gift basket I've ever received! The quality and presentation were top-notch."</p>
<footer class="blockquote-footer mt-3">Anna K.</footer>
</div>
</div>
</div>
<div class="col-md-4 mb-5">
<div class="card testimonial-card text-center p-4">
<img src="https://picsum.photos/seed/avatar2/96/96" class="avatar mx-auto" alt="Customer avatar">
<div class="card-body">
<p class="card-text fst-italic">"Fast delivery and the flowers were so fresh. My go-to for last-minute gifts!"</p>
<footer class="blockquote-footer mt-3">Piotr Z.</footer>
</div>
</div>
</div>
<div class="col-md-4 mb-5">
<div class="card testimonial-card text-center p-4">
<img src="https://picsum.photos/seed/avatar3/96/96" class="avatar mx-auto" alt="Customer avatar">
<div class="card-body">
<p class="card-text fst-italic">"I love the unique items you can't find anywhere else. Highly recommended!"</p>
<footer class="blockquote-footer mt-3">Ewa N.</footer>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact" class="py-5 bg-light">
<div class="container">
<div class="text-center mb-5">
<h2>Get In Touch</h2>
<p class="lead">Have a question or a special request? Let us know!</p>
</div>
<div class="row justify-content-center">
<div class="col-lg-8">
<form id="contactForm" novalidate>
<div id="form-feedback"></div>
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" required>
<div class="invalid-feedback">Please enter your name.</div>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" required>
<div class="invalid-feedback">Please enter a valid email address.</div>
</div>
<div class="mb-3">
<label for="message" class="form-label">Message</label>
<textarea class="form-control" id="message" rows="5" required></textarea>
<div class="invalid-feedback">Please enter your message.</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary btn-lg">Send Message</button>
</div>
</form>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="py-4">
<div class="container text-center">
<p class="mb-2">&copy; <?php echo date("Y"); ?> GiftShop. All Rights Reserved.</p>
<div>
<a href="#" class="text-dark mx-2"><i class="bi bi-facebook"></i></a>
<a href="#" class="text-dark mx-2"><i class="bi bi-instagram"></i></a>
<a href="#" class="text-dark mx-2"><i class="bi bi-pinterest"></i></a>
</div>
<div class="mt-3">
<a href="login.php" class="text-muted">Admin Login</a>
</div>
</div>
</footer>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS -->
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body> </body>
</html> </html>

93
login.php Normal file
View File

@ -0,0 +1,93 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
// If user is already logged in, redirect to admin dashboard
if (isset($_SESSION['user_id'])) {
header('Location: admin/index.php');
exit;
}
$error_message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (empty($username) || empty($password)) {
$error_message = 'Please enter both username and password.';
} else {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username);
$stmt->execute();
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Password is correct, start session
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['user_role'] = $user['role'];
// Redirect to admin dashboard
header('Location: admin/index.php');
exit;
} else {
$error_message = 'Invalid username or password.';
}
} catch (PDOException $e) {
$error_message = 'Database error: ' . $e->getMessage();
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login - GiftShop</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: #FCF8F3;
}
.login-card {
max-width: 400px;
width: 100%;
}
</style>
</head>
<body>
<div class="card login-card shadow-sm">
<div class="card-body p-5">
<h1 class="card-title text-center mb-4">Admin Login</h1>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<form method="POST" action="login.php">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<div class="text-center mt-3">
<a href="index.php"> Back to site</a>
</div>
</div>
</div>
</body>
</html>