35861-vm/index.php
Flatlogic Bot f05220da7c tre
2025-11-19 23:45:40 +00:00

73 lines
3.8 KiB
PHP

<?php require_once 'includes/header.php'; ?>
<div class="main-content">
<!-- Hero Section -->
<header class="hero">
<div class="container">
<h1 class="display-3">The Ultimate Festival & Event Access Pass</h1>
<p class="lead">Your gateway to exclusive guest lists and promotional opportunities at the hottest events.</p>
<a href="#events" class="btn btn-primary btn-lg">Browse Events</a>
</div>
</header>
<!-- Events Section -->
<main id="events" class="event-section">
<div class="container">
<?php if (isset($_SESSION['flash_message'])): ?>
<div class="alert alert-<?php echo $_SESSION['flash_message']['type']; ?> alert-dismissible fade show" role="alert">
<?php echo $_SESSION['flash_message']['message']; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['flash_message']); ?>
<?php endif; ?>
<h2 class="text-center mb-5">Open Events</h2>
<div class="row">
<?php
require_once 'db/config.php';
// Fetch open events from the database
$pdo = db();
$stmt = $pdo->query('SELECT * FROM events WHERE is_open = TRUE ORDER BY event_date ASC');
$events = $stmt->fetchAll();
// If user is logged in, get their applications
$user_applications = [];
if (isset($_SESSION['user']['id'])) {
$app_stmt = $pdo->prepare('SELECT event_id FROM applications WHERE user_id = ?');
$app_stmt->execute([$_SESSION['user']['id']]);
$user_applications = $app_stmt->fetchAll(PDO::FETCH_COLUMN);
}
foreach ($events as $event):
$imageUrl = !empty($event['image_url']) ? $event['image_url'] : 'https://images.pexels.com/photos/2263436/pexels-photo-2263436.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2';
?>
<div class="col-lg-4 col-md-6">
<div class="card event-card">
<img src="<?php echo htmlspecialchars($imageUrl); ?>" class="card-img-top" alt="Event Image">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($event['title']); ?></h5>
<p class="card-text text-muted"><?php echo date("M d, Y", strtotime($event['event_date'])); ?> &bull; <?php echo htmlspecialchars($event['location']); ?></p>
<?php if (isset($_SESSION['user']['id']) && $_SESSION['user']['role'] === 'user'): ?>
<?php if (in_array($event['id'], $user_applications)): ?>
<button class="btn btn-success" disabled>Applied</button>
<?php else: ?>
<form action="apply.php" method="POST" style="display: inline;">
<input type="hidden" name="event_id" value="<?php echo $event['id']; ?>">
<button type="submit" class="btn btn-secondary">Apply Now</button>
</form>
<?php endif; ?>
<?php elseif (!isset($_SESSION['user']['id'])):
?>
<a href="login.php" class="btn btn-secondary">Login to Apply</a>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</main>
</div>
<?php require_once 'includes/footer.php'; ?>