153 lines
4.1 KiB
PHP
153 lines
4.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
session_set_cookie_params(['path' => '/']);
|
|
session_start();
|
|
|
|
// If the user is not logged in, redirect to the login page
|
|
if (!isset($_SESSION['user'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$eventsJson = file_get_contents('events.json');
|
|
$events = json_decode($eventsJson, true);
|
|
|
|
$newEvent = [
|
|
'title' => $_POST['title'],
|
|
'date' => $_POST['date'],
|
|
'time' => $_POST['time'],
|
|
'details' => $_POST['details']
|
|
];
|
|
|
|
$events[] = $newEvent;
|
|
|
|
file_put_contents('events.json', json_encode($events, JSON_PRETTY_PRINT));
|
|
|
|
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" />
|
|
<title>Create Event</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<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">
|
|
<style>
|
|
:root {
|
|
--bg-color-start: #6a11cb;
|
|
--bg-color-end: #2575fc;
|
|
--text-color: #ffffff;
|
|
--card-bg-color: rgba(255, 255, 255, 0.05);
|
|
--card-border-color: rgba(255, 255, 255, 0.2);
|
|
--button-text-color: #2575fc;
|
|
--input-bg-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;
|
|
}
|
|
main {
|
|
padding: 2rem;
|
|
width: 80%;
|
|
max-width: 600px;
|
|
}
|
|
.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);
|
|
text-align: left;
|
|
}
|
|
h1 {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
margin-bottom: 2rem;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
font-weight: 700;
|
|
}
|
|
input, textarea {
|
|
width: 100%;
|
|
padding: 1rem;
|
|
border-radius: 8px;
|
|
border: 1px solid var(--card-border-color);
|
|
background-color: var(--input-bg-color);
|
|
color: var(--text-color);
|
|
font-family: 'Inter', sans-serif;
|
|
font-size: 1rem;
|
|
box-sizing: border-box;
|
|
}
|
|
button {
|
|
background-color: var(--text-color);
|
|
color: var(--button-text-color);
|
|
border: none;
|
|
padding: 1rem 2rem;
|
|
border-radius: 8px;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s, color 0.3s;
|
|
width: 100%;
|
|
font-size: 1rem;
|
|
}
|
|
button:hover {
|
|
background-color: #f0f0f0;
|
|
}
|
|
.back-link {
|
|
display: block;
|
|
text-align: center;
|
|
margin-top: 2rem;
|
|
color: var(--text-color);
|
|
text-decoration: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div class="card">
|
|
<h1>Create New Event</h1>
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label for="title">Event Title</label>
|
|
<input type="text" id="title" name="title" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="date">Date</label>
|
|
<input type="date" id="date" name="date" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="time">Time</label>
|
|
<input type="time" id="time" name="time" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="details">Details</label>
|
|
<textarea id="details" name="details" rows="4" required></textarea>
|
|
</div>
|
|
<button type="submit">Create Event</button>
|
|
</form>
|
|
<a href="index.php" class="back-link">Back to Dashboard</a>
|
|
</div>
|
|
</main>
|
|
</body>
|
|
</html>
|