-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome_page_admin.php
More file actions
236 lines (192 loc) · 10.1 KB
/
Copy pathhome_page_admin.php
File metadata and controls
236 lines (192 loc) · 10.1 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php
session_start();
include("functions.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Home Page | WGC</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!--More CSS features by author-->
<link rel="stylesheet" href="style_WestGames.css">
</head>
<body>
<nav class="navbar navbar-expand-xl navbar-light" style="background-color: #FAFFF2;">
<a class="navbar-brand" href="home_page_admin.php">West Games Club</a>
<p class="mr-auto" id="welcomeMsg"> Welcome <?php
$id = $_SESSION['id'];
$query = "SELECT Users.firstName FROM Users WHERE id=" . $id;
$result = mysqli_query($link, $query);
$row = mysqli_fetch_assoc($result);
echo($row['firstName']) ?>!</p>
<!--nav bar toggler-->
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">
<span class="navbar-toggler-icon"></span>
</button>
<!--nav bar with menu and collapse features-->
<div class="collapse navbar-collapse" id="navbarCollapse">
<form class="navbar-form navbar-right form-inline ml-auto" method="post">
<div class="form-group">
<input type="text" id="searchGame" name="searchGame" placeholder="search a game"
class="form-control mr-2"
value="<?php echo addslashes($_POST['searchGame']); ?>"/>
<input type="submit" name="submit" class="btn btn-success my-2 my-sm-0" value="Search Game">
</div>
</form>
<ul class="navbar-nav mr-auto ml-auto">
<li class="nav-item active dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Admin Functions
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="list_matches.php">List of Matches</a>
<a class="dropdown-item" href="leader_board_game.php">Leader Board - Game</a>
<a class="dropdown-item" href="leader_board_member.php">Leader Board - Member</a>
<a class="dropdown-item" href="won_percentage.php">Statics: Won-Played Percentage</a>
<a class="dropdown-item" href="matches_per_day.php">Statics: Number of Matches per Day</a>
<a class="dropdown-item" href="game_list.php">Game Management</a>
</div>
</li>
<li class="nav-item active">
<a class="nav-link" href="home_page_admin.php">Home Page <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="game_record_admin.php">Record Game</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="index.php?logout=1">Log Out</a>
</li>
</ul>
</div>
</nav>
<!--contents on page-->
<div class="jumbotron jumbotron-fluid">
<div class="container text-center">
<?php displayError(); ?>
<div class="row">
<form method="post" class="form-group mx-auto">
<table class="table-sm table-bordered table-dark">
<h4 class="display-5">Account Information</h4>
<thead>
<?php
$query = "SELECT Users.id, Users.userName, Users.firstName, Users.lastName, Users.userType FROM Users WHERE id=" . $_SESSION['id'];
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td>User ID</td>
<td><?php echo $row["id"]; ?></td>
</tr>
<tr>
<td>User Name</td>
<td><?php echo $row["userName"]; ?></td>
</tr>
<tr>
<td>First Name</td>
<td><?php echo $row["firstName"]; ?></td>
</tr>
<tr>
<td>Last Name</td>
<td><?php echo $row["lastName"]; ?></td>
</tr>
<tr>
<td>User Type</td>
<td><?php echo $row["userType"]; ?></td>
</tr>
<?php } ?>
</thead>
</table>
</form>
</div>
<div class="row">
<form method="post" class="mx-auto">
<table class="table table-striped table-bordered table-dark">
<h4 class="display-5">Your recent play records</h4>
<div class="input-group mb-3">
<input type="text" name="q" class="form-control"
placeholder="Search win records by game name" aria-describedby="basic-addon2">
<div class="input-group-append">
<input type="submit" name="submit" value="Filter" class="btn btn-primary mr-3">
<input type="submit" name="submit" value="All records" class="btn btn-primary">
</div>
</div>
<thead>
<tr>
<td>Match ID</td>
<td>Game Name</td>
<td>Match Date</td>
<td>Game Result</td>
</tr>
</thead>
<tbody>
<?php
if (!$_POST['submit'] == "Filter") {
$query = "SELECT Games.gameID, Games.gameName, Matches.matchID, Results.matchResult, Results.matchDate, Results.userID FROM Games JOIN Matches ON Games.gameID = Matches.gameID JOIN Results ON Matches.matchID = Results.matchID WHERE userID='" . $_SESSION['id'] . "'ORDER BY Results.matchID";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td><?php echo $row["matchID"]; ?></td>
<td><?php echo $row["gameName"]; ?></td>
<td><?php echo $row["matchDate"]; ?></td>
<td><?php echo $row["matchResult"]; ?></td>
</tr>
<?php }
} else if ($_POST['submit']=="All records") {
$query = "SELECT Games.gameID, Games.gameName, Matches.matchID, Results.matchResult, Results.matchDate, Results.userID FROM Games JOIN Matches ON Games.gameID = Matches.gameID JOIN Results ON Matches.matchID = Results.matchID WHERE userID='" . $_SESSION['id'] . "'ORDER BY Results.matchID";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td><?php echo $row["matchID"]; ?></td>
<td><?php echo $row["gameName"]; ?></td>
<td><?php echo $row["matchDate"]; ?></td>
<td><?php echo $row["matchResult"]; ?></td>
</tr>
<?php }
} else {
if ($_POST['submit'] =="Filter") {
$q = $link->real_escape_string($_POST['q']);
$sql = $link->query("SELECT Games.gameID, Games.gameName, Matches.matchID, Results.matchResult, Results.matchDate, Results.userID FROM Games JOIN Matches ON Games.gameID = Matches.gameID JOIN Results ON Matches.matchID = Results.matchID WHERE userID='" . $_SESSION['id'] . "'AND gameName LIKE '%$q%'");
if ($sql->num_rows > 0) {
while ($row = $sql->fetch_array()) { ?>
<tr>
<td><?php echo $row["matchID"]; ?></td>
<td><?php echo $row["gameName"]; ?></td>
<td><?php echo $row["matchDate"]; ?></td>
<td><?php echo $row["matchResult"]; ?></td>
</tr>
<?php }
}
}
}
?>
</tbody>
</table>
</form>
</div>
</div>
</div>
<!--footer-->
<div class="footer">
<div class="view1">
Copyright © 2019 West Games Club
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
</body>
</html>