Compare commits

...

2 Commits

Author SHA1 Message Date
Flatlogic Bot
298521e30e bb 2026-01-09 01:55:06 +00:00
Flatlogic Bot
2369b242ea enviroment 2026-01-09 01:34:44 +00:00
19 changed files with 1003 additions and 145 deletions

70
admin_dashboard.php Normal file
View File

@ -0,0 +1,70 @@
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header('Location: login.php');
exit();
}
require_once 'db/config.php';
$conn = db();
// Fetch pending events
$stmt = $conn->prepare("SELECT events.*, users.name as manager_name FROM events JOIN users ON events.created_by = users.id WHERE events.status = 'pending' ORDER BY events.created_at DESC");
$stmt->execute();
$events = $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 - EventPlatform</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?v=<?php echo time(); ?>">
</head>
<body>
<?php require_once './includes/header.php'; ?>
<div class="container mt-5">
<h1 class="mb-4">Admin Dashboard</h1>
<div class="card">
<div class="card-header">
Pending Events
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Event Name</th>
<th>Manager</th>
<th>Date</th>
<th>Location</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($events as $event): ?>
<tr>
<td><?php echo htmlspecialchars($event['name']); ?></td>
<td><?php echo htmlspecialchars($event['manager_name']); ?></td>
<td><?php echo htmlspecialchars($event['date']); ?></td>
<td><?php echo htmlspecialchars($event['location']); ?></td>
<td>
<a href="update_event_status.php?id=<?php echo $event['id']; ?>&status=accepted" class="btn btn-success btn-sm">Approve</a>
<a href="update_event_status.php?id=<?php echo $event['id']; ?>&status=rejected" class="btn btn-danger btn-sm">Reject</a>
</td>
</tr>
<?php endforeach; ?>
</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>

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

@ -0,0 +1,108 @@
:root {
--primary-color: #4F46E5;
--secondary-color: #10B981;
--bg-light: #F9FAFB;
--surface-white: #FFFFFF;
--text-dark: #111827;
--text-muted: #6B7280;
}
body {
background-color: var(--bg-light);
font-family: 'Inter', sans-serif;
color: var(--text-dark);
}
.navbar-brand {
font-weight: 700;
}
.hero-section {
background: linear-gradient(120deg, var(--primary-color) 0%, #7c3aed 100%);
padding: 6rem 0;
color: white;
}
.hero-section h1 {
font-size: 3.5rem;
font-weight: 800;
}
.hero-section p {
font-size: 1.25rem;
max-width: 600px;
margin: 1rem auto 2rem;
}
.btn-primary {
background-color: var(--primary-color);
border-color: var(--primary-color);
font-weight: 600;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
transition: background-color 0.2s ease-in-out;
}
.btn-primary:hover {
background-color: #4338ca;
border-color: #4338ca;
}
.event-section {
padding: 5rem 0;
}
.event-card {
border: none;
border-radius: 0.75rem;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
height: 100%;
}
.event-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.event-card .card-body {
padding: 1.75rem;
}
.event-card .card-title {
font-size: 1.25rem;
font-weight: 600;
color: var(--text-dark);
}
.event-card .card-subtitle {
color: var(--primary-color);
font-weight: 500;
}
.event-card .card-text {
color: var(--text-muted);
}
.price-tag {
background-color: var(--secondary-color);
color: white;
font-weight: 700;
font-size: 1.1rem;
padding: 0.5rem 1rem;
border-radius: 0.5rem;
position: absolute;
top: 1.5rem;
right: 1.5rem;
}
.price-tag.free {
background-color: var(--primary-color);
}
.footer {
background-color: var(--surface-white);
padding: 2rem 0;
border-top: 1px solid #e5e7eb;
}

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

@ -0,0 +1 @@
// Future JavaScript enhancements will go here.

32
buy_ticket.php Normal file
View File

@ -0,0 +1,32 @@
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit();
}
if (!isset($_GET['id'])) {
header('Location: index.php');
exit();
}
require_once 'db/config.php';
$event_id = $_GET['id'];
$user_id = $_SESSION['user_id'];
try {
$conn = db();
$stmt = $conn->prepare("INSERT INTO tickets (user_id, event_id) VALUES (:user_id, :event_id)");
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
$stmt->bindParam(':event_id', $event_id, PDO::PARAM_INT);
$stmt->execute();
header('Location: my_tickets.php?success=ticket_purchased');
exit();
} catch (PDOException $e) {
// Handle database error
header('Location: event_details.php?id=' . $event_id . '&error=db_error');
exit();
}

41
create_event.php Normal file
View File

@ -0,0 +1,41 @@
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'manager') {
header('Location: login.php');
exit();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
require_once 'db/config.php';
$name = $_POST['name'] ?? '';
$description = $_POST['description'] ?? '';
$date = $_POST['date'] ?? '';
$location = $_POST['location'] ?? '';
$manager_id = $_SESSION['user_id'];
if (empty($name) || empty($description) || empty($date) || empty($location)) {
// Handle empty fields
header('Location: manager_dashboard.php?error=empty_fields');
exit();
}
try {
$conn = db();
$stmt = $conn->prepare("INSERT INTO events (name, description, date, location, status, created_by) VALUES (:name, :description, :date, :location, 'pending', :created_by)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':description', $description);
$stmt->bindParam(':date', $date);
$stmt->bindParam(':location', $location);
$stmt->bindParam(':created_by', $manager_id, PDO::PARAM_INT);
$stmt->execute();
header('Location: manager_dashboard.php?success=event_created');
exit();
} catch (PDOException $e) {
// Handle database error
header('Location: manager_dashboard.php?error=db_error');
exit();
}
}

View File

@ -0,0 +1,37 @@
<?php
require_once __DIR__ . '/../config.php';
try {
$pdo = db();
// Create events table
$pdo->exec("CREATE TABLE IF NOT EXISTS events (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
event_date DATETIME NOT NULL,
location VARCHAR(255),
price DECIMAL(10, 2) DEFAULT 0.00,
status ENUM('pending', 'accepted', 'rejected') NOT NULL DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);");
// Check if table is empty before seeding
$stmt = $pdo->query("SELECT COUNT(*) FROM events");
if ($stmt->fetchColumn() == 0) {
// Seed data
$pdo->exec("INSERT INTO events (title, event_date, location, status, price) VALUES
('Community Tech Conference 2026', '2026-03-15 09:00:00', 'City Convention Center', 'accepted', 49.99),
('Local Music Festival', '2026-04-22 18:00:00', 'Downtown Park', 'accepted', 25.00),
('Art & Design Expo', '2026-05-10 11:00:00', 'Grand Exhibition Hall', 'pending', 15.00),
('Startup Pitch Night', '2026-05-20 19:00:00', 'Innovation Hub', 'accepted', 0.00),
('Health & Wellness Retreat', '2026-06-05 10:00:00', 'Serenity Resort', 'rejected', 350.00);
");
echo "Database table 'events' created and seeded successfully." . PHP_EOL;
} else {
echo "Database table 'events' already exists and contains data. Seeding skipped." . PHP_EOL;
}
} catch (PDOException $e) {
die("Database migration failed: " . $e->getMessage());
}

View File

@ -0,0 +1,25 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('user', 'manager', 'admin') NOT NULL DEFAULT 'user',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=INNODB;
";
$pdo->exec($sql);
echo "Migration 002 completed successfully: 'users' table created." . PHP_EOL;
} catch (PDOException $e) {
die("Migration 002 failed: " . $e->getMessage());
}
?>

View File

@ -0,0 +1,17 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$conn = db();
$sql = "ALTER TABLE users ADD COLUMN role VARCHAR(255) NOT NULL DEFAULT 'user'";
$conn->exec($sql);
// Set user with id 1 to be an admin
$sql_admin = "UPDATE users SET role = 'admin' WHERE id = 1";
$conn->exec($sql_admin);
// Set user with id 2 to be a manager
$sql_manager = "UPDATE users SET role = 'manager' WHERE id = 2";
$conn->exec($sql_manager);
echo "Migration successful: 'role' column added to 'users' table and default users updated." . PHP_EOL;
} catch (PDOException $e) {
echo "Migration failed: " . $e->getMessage() . PHP_EOL;
}

View File

@ -0,0 +1,11 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$conn = db();
$sql = "ALTER TABLE events ADD COLUMN created_by INT(11) NULL, ADD FOREIGN KEY (created_by) REFERENCES users(id)";
$conn->exec($sql);
echo "Migration successful: 'created_by' column added to 'events' table." . PHP_EOL;
} catch (PDOException $e) {
echo "Migration failed: " . $e->getMessage() . PHP_EOL;
}

View File

@ -0,0 +1,18 @@
<?php
require_once __DIR__ . '/../../db/config.php';
try {
$conn = db();
$sql = "CREATE TABLE IF NOT EXISTS tickets (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
event_id INT NOT NULL,
purchase_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (event_id) REFERENCES events(id)
)";
$conn->exec($sql);
echo "Migration successful: 'tickets' table created." . PHP_EOL;
} catch (PDOException $e) {
echo "Migration failed: " . $e->getMessage() . PHP_EOL;
}

59
event_details.php Normal file
View File

@ -0,0 +1,59 @@
<?php
session_start();
if (!isset($_GET['id'])) {
header('Location: index.php');
exit();
}
require_once 'db/config.php';
$conn = db();
$event_id = $_GET['id'];
// Fetch event details
$stmt = $conn->prepare("SELECT * FROM events WHERE id = :id AND status = 'accepted'");
$stmt->bindParam(':id', $event_id, PDO::PARAM_INT);
$stmt->execute();
$event = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$event) {
header('Location: index.php');
exit();
}
$event_date = new DateTime($event['date']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($event['name']); ?> - EventPlatform</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?v=<?php echo time(); ?>">
</head>
<body>
<?php require_once './includes/header.php'; ?>
<div class="container mt-5">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="card">
<div class="card-body">
<h1 class="card-title"><?php echo htmlspecialchars($event['name']); ?></h1>
<h5 class="card-subtitle mb-2 text-muted"><?php echo $event_date->format('l, F j, Y'); ?></h5>
<p class="card-text"><i class="bi bi-geo-alt-fill"></i> <?php echo htmlspecialchars($event['location']); ?></p>
<p class="card-text"><?php echo nl2br(htmlspecialchars($event['description'])); ?></p>
<a href="buy_ticket.php?id=<?php echo $event['id']; ?>" class="btn btn-primary">Buy Ticket</a>
</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>

45
includes/header.php Normal file
View File

@ -0,0 +1,45 @@
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
?>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">EventPlatform</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="index.php">Home</a>
</li>
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item">
<a class="nav-link" href="my_tickets.php">My Tickets</a>
</li>
<?php if ($_SESSION['role'] === 'manager'): ?>
<li class="nav-item">
<a class="nav-link" href="manager_dashboard.php">Manager Dashboard</a>
</li>
<?php endif; ?>
<?php if ($_SESSION['role'] === 'admin'): ?>
<li class="nav-item">
<a class="nav-link" href="admin_dashboard.php">Admin Dashboard</a>
</li>
<?php endif; ?>
<li class="nav-item">
<a class="nav-link" href="logout.php">Logout</a>
</li>
<?php else: ?>
<li class="nav-item">
<a class="nav-link" href="login.php">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="register.php">Register</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>

206
index.php
View File

@ -1,150 +1,82 @@
<?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>EventPlatform - Your Gateway to Exclusive Events</title>
<?php
// Read project preview data from environment <meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Find and book tickets for the best events in town.'); ?>">
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; <!-- Open Graph / Twitter Card meta tags are managed by the platform. Do not add them here. -->
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
:root {
--bg-color-start: #6a11cb; <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
--bg-color-end: #2575fc;
--text-color: #ffffff;
--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>
<?php require_once './includes/header.php'; ?>
<main> <main>
<div class="card"> <section class="hero-section text-center">
<h1>Analyzing your requirements and generating your website…</h1> <div class="container">
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <h1>Discover Your Next Great Event</h1>
<span class="sr-only">Loading…</span> <p>From tech conferences to music festivals, find and book your ticket to the most exciting events happening near you.</p>
<a href="#events" class="btn btn-primary btn-lg">Browse Events</a>
</div> </div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> </section>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p> <section id="events" class="event-section">
<div class="container">
<h2 class="text-center mb-5 fw-bold">Upcoming Events</h2>
<div class="row g-4">
<?php
try {
require_once __DIR__ . '/db/config.php';
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM events WHERE status = 'accepted' ORDER BY date ASC");
$stmt->execute();
$events = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (empty($events)) {
echo "<p class='text-center text-muted'>No upcoming events found. Please check back later!</p>";
} else {
foreach ($events as $event) {
$event_date = new DateTime($event['date']);
echo '<div class="col-lg-4 col-md-6">
<div class="card event-card">
<div class="card-body position-relative">
<h5 class="card-subtitle mb-2 text-muted">' . $event_date->format('M d, Y') . '</h5>
<h4 class="card-title mb-2">' . htmlspecialchars($event['name']) . '</h4>
<p class="card-text"><i class="bi bi-geo-alt-fill"></i> ' . htmlspecialchars($event['location']) . '</p>
<a href="event_details.php?id=' . $event['id'] . '" class="btn btn-outline-primary stretched-link">View Details</a>
</div> </div>
</div>
</div>';
}
}
} catch (Exception $e) {
error_log("Event Fetch Error: " . $e->getMessage());
echo "<p class='text-center text-danger'>We're sorry, but there was an error fetching events. Please try again later.</p>";
}
?>
</div>
</div>
</section>
</main> </main>
<footer> <footer class="footer">
Page updated: <?= htmlspecialchars($now) ?> (UTC) <div class="container text-center">
<p class="text-muted mb-0">&copy; <?php echo date("Y"); ?> EventJet. All rights reserved.</p>
</div>
</footer> </footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body> </body>
</html> </html>

111
login.php Normal file
View File

@ -0,0 +1,111 @@
<?php
// If user is already logged in, redirect to home page
if (isset($_SESSION['user_id'])) {
header("Location: index.php");
exit();
}
require_once 'db/config.php';
$email = '';
$errors = [];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'A valid email is required.';
}
if (empty($password)) {
$errors[] = 'Password is required.';
}
if (empty($errors)) {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT id, name, email, password, role FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
// Password is correct, start session
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['name'];
$_SESSION['user_role'] = $user['role'];
// Redirect to home page
header("Location: index.php");
exit();
} else {
$errors[] = 'Invalid email or password.';
}
} catch (PDOException $e) {
$errors[] = "Database error: Could not log in.";
// In a real app, you would log this error.
// error_log("Login failed: " . $e->getMessage());
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Event Platform</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body class="bg-light">
<?php require_once './includes/header.php'; ?>
<main class="container mt-5 pt-5">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-5">
<div class="card border-0 shadow-lg">
<div class="card-body p-4 p-md-5">
<h2 class="card-title text-center mb-4" style="font-weight: 700;">Login to Your Account</h2>
<?php if (!empty($errors)): ?>
<div class="alert alert-danger" role="alert">
<?php foreach ($errors as $error): ?>
<p class="mb-0"><?php echo htmlspecialchars($error); ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<form action="login.php" method="POST" novalidate>
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
</div>
<div class="mb-4">
<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 btn-lg" style="background-color: #4F46E5;">Login</button>
</div>
</form>
<p class="text-center mt-4">
Don't have an account? <a href="register.php">Sign up</a>
</p>
</div>
</div>
</div>
</div>
</main>
<footer class="text-center py-4 text-muted fixed-bottom bg-light">
<p>&copy; <?php echo date("Y"); ?> EventPlatform. All rights reserved.</p>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

23
logout.php Normal file
View File

@ -0,0 +1,23 @@
<?php
session_start();
// Unset all of the session variables.
$_SESSION = [];
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
// Redirect to homepage
header("Location: index.php");
exit();
?>

97
manager_dashboard.php Normal file
View File

@ -0,0 +1,97 @@
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'manager') {
header('Location: login.php');
exit();
}
require_once 'db/config.php';
$conn = db();
$manager_id = $_SESSION['user_id'];
// Fetch events created by the manager
$stmt = $conn->prepare("SELECT * FROM events WHERE created_by = :manager_id ORDER BY created_at DESC");
$stmt->bindParam(':manager_id', $manager_id, PDO::PARAM_INT);
$stmt->execute();
$events = $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>Manager Dashboard - EventPlatform</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?v=<?php echo time(); ?>">
</head>
<body>
<?php require_once './includes/header.php'; ?>
<div class="container mt-5">
<h1 class="mb-4">Manager Dashboard</h1>
<div class="card mb-4">
<div class="card-header">
Create New Event
</div>
<div class="card-body">
<form action="create_event.php" method="POST">
<div class="mb-3">
<label for="name" class="form-label">Event Name</label>
<input type="text" class="form-control" id="name" name="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" required></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="date" class="form-label">Date</label>
<input type="date" class="form-control" id="date" name="date" required>
</div>
<div class="col-md-6 mb-3">
<label for="location" class="form-label">Location</label>
<input type="text" class="form-control" id="location" name="location" required>
</div>
</div>
<button type="submit" class="btn btn-primary">Create Event</button>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
Your Events
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Location</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($events as $event): ?>
<tr>
<td><?php echo htmlspecialchars($event['name']); ?></td>
<td><?php echo htmlspecialchars($event['date']); ?></td>
<td><?php echo htmlspecialchars($event['location']); ?></td>
<td><span class="badge bg-<?php echo $event['status'] === 'accepted' ? 'success' : ($event['status'] === 'rejected' ? 'danger' : 'warning'); ?>"><?php echo htmlspecialchars(ucfirst($event['status'] ?? '')); ?></span></td>
</tr>
<?php endforeach; ?>
</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>

66
my_tickets.php Normal file
View File

@ -0,0 +1,66 @@
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit();
}
require_once 'db/config.php';
$conn = db();
$user_id = $_SESSION['user_id'];
// Fetch tickets for the user
$stmt = $conn->prepare("SELECT events.name, events.date, events.location FROM tickets JOIN events ON tickets.event_id = events.id WHERE tickets.user_id = :user_id ORDER BY events.date ASC");
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
$stmt->execute();
$tickets = $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>My Tickets - EventPlatform</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?v=<?php echo time(); ?>">
</head>
<body>
<?php require_once './includes/header.php'; ?>
<div class="container mt-5">
<h1 class="mb-4">My Tickets</h1>
<div class="card">
<div class="card-header">
Your Purchased Tickets
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<tr>
<th>Event Name</th>
<th>Date</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<?php foreach ($tickets as $ticket): ?>
<tr>
<td><?php echo htmlspecialchars($ticket['name']); ?></td>
<td><?php echo htmlspecialchars($ticket['date']); ?></td>
<td><?php echo htmlspecialchars($ticket['location']); ?></td>
</tr>
<?php endforeach; ?>
</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>

134
register.php Normal file
View File

@ -0,0 +1,134 @@
<?php
require_once 'db/config.php';
$name = '';
$email = '';
$errors = [];
$success_message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
$password_confirm = $_POST['password_confirm'] ?? '';
if (empty($name)) {
$errors[] = 'Name is required.';
}
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'A valid email is required.';
} else {
$pdo = db();
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$errors[] = 'Email address is already in use.';
}
}
if (empty($password)) {
$errors[] = 'Password is required.';
} elseif (strlen($password) < 8) {
$errors[] = 'Password must be at least 8 characters long.';
} elseif ($password !== $password_confirm) {
$errors[] = 'Passwords do not match.';
}
if (empty($errors)) {
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO users (name, email, password, role) VALUES (?, ?, ?, 'user')");
$stmt->execute([$name, $email, $hashed_password]);
$success_message = 'Registration successful! You can now <a href="login.php" class="alert-link">log in</a>.';
// Clear form fields on success
$name = '';
$email = '';
} catch (PDOException $e) {
$errors[] = "Database error: Could not register user.";
// In a real app, you would log this error.
// error_log("Registration failed: " . $e->getMessage());
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register - Event Platform</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body class="bg-light">
<?php require_once './includes/header.php'; ?>
<main class="container mt-5 pt-5">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-5">
<div class="card border-0 shadow-lg">
<div class="card-body p-4 p-md-5">
<h2 class="card-title text-center mb-4" style="font-weight: 700;">Create Your Account</h2>
<?php if (!empty($errors)): ?>
<div class="alert alert-danger" role="alert">
<?php foreach ($errors as $error): ?>
<p class="mb-0"><?php echo htmlspecialchars($error); ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($success_message): ?>
<div class="alert alert-success" role="alert">
<?php echo $success_message; ?>
</div>
<?php endif; ?>
<?php if (!$success_message): ?>
<form action="register.php" method="POST" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Full Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" 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 class="form-text">Password must be at least 8 characters long.</div>
</div>
<div class="mb-4">
<label for="password_confirm" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="password_confirm" name="password_confirm" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg" style="background-color: #4F46E5;">Register</button>
</div>
</form>
<?php endif; ?>
<p class="text-center mt-4">
Already have an account? <a href="login.php">Log in</a>
</p>
</div>
</div>
</div>
</div>
</main>
<footer class="text-center py-4 text-muted fixed-bottom bg-light">
<p>&copy; <?php echo date("Y"); ?> EventPlatform. All rights reserved.</p>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

31
update_event_status.php Normal file
View File

@ -0,0 +1,31 @@
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header('Location: login.php');
exit();
}
if (isset($_GET['id']) && isset($_GET['status'])) {
require_once 'db/config.php';
$event_id = $_GET['id'];
$status = $_GET['status'];
if ($status === 'accepted' || $status === 'rejected') {
try {
$conn = db();
$stmt = $conn->prepare("UPDATE events SET status = :status WHERE id = :id");
$stmt->bindParam(':status', $status);
$stmt->bindParam(':id', $event_id, PDO::PARAM_INT);
$stmt->execute();
} catch (PDOException $e) {
// Handle database error
header('Location: admin_dashboard.php?error=db_error');
exit();
}
}
}
header('Location: admin_dashboard.php');
exit();