0.3 Back button on Edit Events
This commit is contained in:
parent
8e8aeb4a48
commit
de65f7432a
152
create_event.php
Normal file
152
create_event.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?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>
|
||||||
@ -103,7 +103,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
}
|
}
|
||||||
button {
|
button, .button {
|
||||||
background-color: var(--text-color);
|
background-color: var(--text-color);
|
||||||
color: var(--button-text-color);
|
color: var(--button-text-color);
|
||||||
border: none;
|
border: none;
|
||||||
@ -112,8 +112,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
transition: background-color 0.3s, color 0.3s;
|
transition: background-color 0.3s, color 0.3s;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
button:hover {
|
button:hover, .button:hover {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -136,6 +138,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
<textarea id="details" name="details" rows="4" required><?= htmlspecialchars($event['details']) ?></textarea>
|
<textarea id="details" name="details" rows="4" required><?= htmlspecialchars($event['details']) ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Update Event</button>
|
<button type="submit">Update Event</button>
|
||||||
|
<a href="index.php" class="button">Back</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@ -129,7 +129,10 @@ $user = $_SESSION['user'];
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="schedule">
|
<div class="schedule">
|
||||||
|
<div class="header">
|
||||||
<h2>Event Schedule</h2>
|
<h2>Event Schedule</h2>
|
||||||
|
<a href="create_event.php" class="logout">Create New Event</a>
|
||||||
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$eventsJson = file_get_contents('events.json');
|
$eventsJson = file_get_contents('events.json');
|
||||||
$events = json_decode($eventsJson, true);
|
$events = json_decode($eventsJson, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user