-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_event.php
More file actions
177 lines (143 loc) · 5.53 KB
/
edit_event.php
File metadata and controls
177 lines (143 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ob_start();
session_start();
require_once 'db.php';
// To check if event ID is provided in the URL
if (isset($_GET['id'])) {
$eventId = $_GET['id'];
// To fetch event details from the database
$stmt = $db->prepare("SELECT * FROM events WHERE id = ?");
$stmt->execute([$eventId]);
$event = $stmt->fetch(PDO::FETCH_ASSOC);
// To check if the event exists
if (!$event) {
echo "Event not found.";
exit;
}
// Handling form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieving form data
$eventName = $_POST['eventName'];
$eventDate = $_POST['eventDate'];
$eventTime = $_POST['eventTime'];
$eventVenue = $_POST['eventVenue'];
$organizingParty = $_POST['organizingParty'];
try {
// Update event data in the database
$stmt = $db->prepare("UPDATE events SET name = ?, event_date = ?, event_time = ?, venue = ?, organizing_party = ? WHERE id = ?");
$stmt->execute([$eventName, $eventDate, $eventTime, $eventVenue, $organizingParty, $eventId]);
echo "Event updated successfully";
// Redirect to event management page after updating the event
header("Location: event_management.php");
exit;
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
} else {
echo "Event ID not provided.";
exit;
}
// Check if the user is logged in
$isLoggedIn = isset($_SESSION['user_id']) && $_SESSION['user_id'] !== null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Event</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="TemplateMo">
<link
href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Additional CSS Files -->
<link rel="stylesheet" href="assets/css/fontawesome.css">
<link rel="stylesheet" href="assets/css/templatemo-stand-blog.css">
<link rel="stylesheet" href="assets/css/owl.css">
<style>
h2 {
color: #333;
text-align: center;
font-size: 22px;
font-weight: bold;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 80%;
max-width: 500px;
margin: 50px auto;
}
label {
display: block;
margin-bottom: 10px;
color: #555;
}
input[type="text"],
input[type="date"],
input[type="time"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 16px;
}
button[type="submit"] {
background-color: #0d7b99;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
font-size: 16px;
}
button[type="submit"]:hover {
color: #0d7b99;
background-color: #fff;
border: 1px solid #0d7b99;
border-color: #0d7b99;
}
.header-1 {
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<?php include 'header.php'; ?>
<div class="heading-page header-text">
<!-- to get the space between the header and event management -->
</div>
<form id="eventForm" action="" method="post">
<h2>Edit Event</h2>
<label for="eventName">Event Name:</label>
<input type="text" id="eventName" name="eventName" value="<?php echo $event['name']; ?>" required>
<label for="eventDate">Event Date:</label>
<input type="date" id="eventDate" name="eventDate" value="<?php echo $event['event_date']; ?>" required>
<label for="eventTime">Event Time:</label>
<input type="time" id="eventTime" name="eventTime" value="<?php echo $event['event_time']; ?>" required>
<label for="eventVenue">Venue:</label>
<input type="text" id="eventVenue" name="eventVenue" value="<?php echo $event['venue']; ?>" required>
<input type="text" id="organizingParty" name="organizingParty" value="<?php echo $event['organizing_party']; ?>" readonly style="display:none;" required>
<button type="submit">Update Event</button>
</form>
<?php include 'footer.php'; ?>