forked from Demilade362/ticketBooking-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
198 lines (186 loc) · 11.3 KB
/
search.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
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
<?php
include('config/db_connect.php');
session_start();
$name = $_SESSION['adminName'] ?? 'Guest';
$resultsTickets = null;
$resultsUser = null;
$resultsUsedTickets = null;
$searchTickets = null;
$searchUser = null;
$searchUser = null;
if (isset($_GET['search']) && isset($_GET['searchTicket'])) {
$searchTickets = $_GET['searchTicket'];
$sql = "SELECT * FROM tickets WHERE usersname = '$searchTickets'";
$query = mysqli_query($conn, $sql);
$resultsTickets = mysqli_fetch_assoc($query);
}
if (isset($_GET['searchUser']) && isset($_GET['user'])) {
$searchUser = $_GET['user'];
$sql = "SELECT * FROM loginsystem WHERE usersName = '$searchUser'";
$query = mysqli_query($conn, $sql);
$resultsUser = mysqli_fetch_assoc($query);
}
if (isset($_GET['searchUsedTicket']) && isset($_GET['searchUsedTicket'])) {
$searchUser = $_GET['searchUsedTicket'];
$sql = "SELECT * FROM usedTickets WHERE usersName = '$searchUser'";
$query = mysqli_query($conn, $sql);
$resultsUsedTickets = mysqli_fetch_assoc($query);
}
?>
<!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.0">
<title>Query</title>
<link rel="shortcut icon" href="templates/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="dist/css/bootstrap.min.css">
<script defer src="dist/popper.min.js"></script>
<script defer src="dist/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container mt-5">
<div class="d-lg-flex justify-content-between">
<h3>Hello <?php echo $name ?></h3>
<h3>Search Query</h3>
</div>
<div class="mt-5">
<?php if ($resultsTickets) : ?>
<div class="mt-5">
<table class="table bg-white">
<thead>
<tr>
<th scope="col">Tickets Id</th>
<th scope="col">Username</th>
<th scope="col">Email</th>
<th scope="col">Mode of Transport</th>
<th scope="col">Location</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><?php echo $resultsTickets['ticketID'] ?></th>
<td id="username"><?php echo $resultsTickets['usersname'] ?></td>
<td><?php echo $resultsTickets['usersemail'] ?></td>
<td><?php echo $resultsTickets['mode'] ?></td>
<td><?php echo $resultsTickets['localePlace'] ?></td>
<td>
<form action="usedTickets.php" method="POST">
<input type="hidden" name="myId" value="<?php echo $resultsTickets['id'] ?>">
<input type="hidden" name="ticketId" value="<?php echo $resultsTickets['ticketID'] ?>">
<input type="hidden" name="usersname" value="<?php echo $resultsTickets['usersname'] ?>">
<input type="hidden" name="usersemail" value="<?php echo $resultsTickets['usersemail'] ?>">
<input type="hidden" name="mode" value="<?php echo $resultsTickets['mode'] ?>">
<input type="hidden" name="location" value="<?php echo $resultsTickets['localePlace'] ?>">
<button class="btn btn-success" name="useTic" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-ticket-perforated-fill" viewBox="0 0 16 16">
<path d="M0 4.5A1.5 1.5 0 0 1 1.5 3h13A1.5 1.5 0 0 1 16 4.5V6a.5.5 0 0 1-.5.5 1.5 1.5 0 0 0 0 3 .5.5 0 0 1 .5.5v1.5a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 0 11.5V10a.5.5 0 0 1 .5-.5 1.5 1.5 0 1 0 0-3A.5.5 0 0 1 0 6V4.5Zm4-1v1h1v-1H4Zm1 3v-1H4v1h1Zm7 0v-1h-1v1h1Zm-1-2h1v-1h-1v1Zm-6 3H4v1h1v-1Zm7 1v-1h-1v1h1Zm-7 1H4v1h1v-1Zm7 1v-1h-1v1h1Zm-8 1v1h1v-1H4Zm7 1h1v-1h-1v1Z" />
</svg>
Use</button>
</form>
</td>
</tr>
</tbody>
</table>
<div class="text-center">
<a href="adminHome.php" class="btn btn-primary">Back to Homepage</a>
</div>
<?php elseif (!$resultsTickets) : ?>
<div class="text-center">
<div>
<p class="lead">Record Not Found
<span class="spinner-border spinner-border-sm"></span>
</p>
</div>
<a href="adminHome.php" class="btn btn-primary">Back to Homepage</a>
</div>
<?php elseif ($resultsUser) : ?>
<table class="table bg-white">
<thead>
<tr>
<th scope="col">User Id</th>
<th scope="col">Username</th>
<th scope="col">Email</th>
<th scope="col">Created At</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><?php echo $resultsUser['usersId'] ?></th>
<td><?php echo $resultsUser['usersName'] ?></td>
<td><?php echo $resultsUser['usersEmail'] ?></td>
<td><?php echo $resultsUser['createdAt'] ?></td>
<td>
<form action="adminUser.php" method="POST">
<input type="hidden" name="myId" value="<?php echo $resultsUser['usersId'] ?>">
<button class="btn btn-danger" name="submit" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash3" viewBox="0 0 16 16">
<path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z" />
</svg>
Delete User Account </button>
</form>
</td>
</tr>
</tbody>
</table>
<div class="text-center">
<a href="adminUser.php" class="btn btn-primary">Back to Users Page</a>
</div>
<?php elseif (!$resultsUser) : ?>
<div class="text-center">
<div>
<p class="lead">Record Not Found
<span class="spinner-border spinner-border-sm"></span>
</p>
</div>
<a href="adminUser.php" class="btn btn-primary">Back to Homepage</a>
</div>
<?php elseif ($resultsUsedTickets) : ?>
<table class="table bg-white">
<thead>
<tr>
<th scope="col">User Id</th>
<th scope="col">Username</th>
<th scope="col">Mode</th>
<th scope="col">Location</th>
<th scope="col">Used At</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><?php echo $resultsUsedTickets['ticketID'] ?></th>
<td><?php echo $resultsUsedTickets['usersName'] ?></td>
<td><?php echo $resultsUsedTickets['mode'] ?></td>
<td><?php echo $resultsUsedTickets['locale'] ?></td>
<td><?php echo $resultsUsedTickets['UsedAt'] ?></td>
<td>
<form action="usedTickets.php" method="POST">
<input type="hidden" name="myId" value="<?php echo $resultsUsedTickets['Id'] ?>">
<button class="btn btn-danger" name="delete" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash3" viewBox="0 0 16 16">
<path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z" />
</svg>
Delete Used Ticket </button>
</form>
</td>
</tr>
</tbody>
</table>
<div class="text-center">
<a href="usedTickets.php" class="btn btn-primary">Back to Tickets Page</a>
</div>
<?php elseif (!$resultsUsedTickets) : ?>
<div class="text-center">
<div>
<p class="lead">Record Not Found
<span class="spinner-border spinner-border-sm"></span>
</p>
</div>
<a href="usedTickets.php" class="btn btn-primary">Back to Homepage</a>
</div>
<?php endif ?>
</div>
</div>
</body>
</html>