-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
68 lines (60 loc) · 1.44 KB
/
index.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
<?php
require_once "util/sql_queries.php";
function main() {
session_start();
# https://stackoverflow.com/a/15088537
if (!isset($_SESSION['username'])) {
header("Location:sign_in.php");
exit;
}
}
main();
include "includes/head.php";
?>
<body>
<?php
include "includes/header.php";
?>
<main>
<h1>
Home
</h1>
<p>
<?php
printf("Signed in as %s", htmlspecialchars($_SESSION['username']));
?>
(<a href="sign_out.php">sign out</a>)
</p>
<h2>
Create an event
</h2>
<a href="event_create.php">Create an event</a>
<h2>
Upcoming events
</h2>
<?php
$events = get_user_events($_SESSION["username"]);
if (count($events) === 0) {
printf("<p>You don't have any upcoming events!</p>");
} else {
echo<<<EOF
<table>
<tr>
<th>Event name</th>
<th>Date</th>
</tr>
EOF;
foreach ($events as $event) {
printf("<tr>");
printf("<th><a href='event.php?event_id={$event["event_id"]}'>{$event['name']}</a></th>");
printf("<th>{$event['date']}</th>");
printf("</tr>");
}
echo "</table>";
}
?>
</main>
</body>
<?php
include "includes/tail.php";
?>