-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage-event.php
85 lines (67 loc) · 2.3 KB
/
manage-event.php
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
<!doctype html>
<?php
# Redirect to login page if not logged in
if(!$_COOKIE['loggedIn']){
# Redirect browser
header('Location: unauthorized.html');
exit();
}
require_once('db_setup.php');
$sql = "USE jjaco16;";
if ($conn->query($sql) !== TRUE) die("Error using database: " . $conn->error);
# set up query and post it to database
$stmt = $conn->prepare("SELECT * FROM Event WHERE eventID = ?;");
if(!$stmt) die("Error: " . $conn->error);
$stmt->bind_param("s", $_GET['event']);
$stmt->execute();
#store result
$result = $stmt->get_result()->fetch_assoc();
# cleanup
$stmt->close();
$conn->close();
?>
<html lang="en">
<head>
<link rel="stylesheet" href="../css/styles.css">
<meta charset="utf-8">
<title>Zoom Room - Manage Event</title>
</head>
<body>
<?php include 'inc/nav.php'; ?>
<h2>Manage Event #<?php echo $_GET['event'] ?></h2>
<?php
if($result['host'] === $_COOKIE['loggedIn']){
?>
<form action="../updateEvent.php" method="POST">
<input type="hidden" name="eventID" value="<?php echo htmlspecialchars($_GET['event']) ?>">
<label for="event-name">Event Name:</label>
<input type="text" name="event-name" id="event-name" value="<?php echo htmlspecialchars($result['eventName']) ?>">
<br><br>
<label for="datetime-start">Starts:</label>
<input type="datetime-local" name="datetime-start" id="datetime-start" value="<?php echo htmlspecialchars(str_replace(" ","T",$result['startTime'])) ?>">
<br><br>
<label for="datetime-end">Ends:</label>
<input type="datetime-local" name="datetime-end" id="datetime-end" value="<?php echo htmlspecialchars(str_replace(" ","T",$result['endTime'])) ?>">
<br><br>
<label for="room">Room:</label>
<input type="text" name="room" id="room" value="<?php echo htmlspecialchars($result['location']) ?>">
<br><br>
<label for="desc">Description:</label>
<textarea name="desc" id="desc"><?php echo $result['description'] ?></textarea>
<br><br>
<input type="submit" name="action" value="Update event" class="button">
<input type="submit" name="action" value="Delete event" class="button">
<br><br>
</form>
<p id="message"></p>
<?php
} else{
echo "<p id='message'>This is not your event to manage.</p>";
}
?>
<footer>
<p>P1M4 by Johnny Jacobs (8) and Mcvvina Lin (22)</p>
<p>CSC 261 Fall 2017</p>
</footer>
</body>
</html>