-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusedTickets.php
186 lines (164 loc) · 8.99 KB
/
usedTickets.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
<?php
include_once('config/db_connect.php');
session_start();
if (isset($_POST['useTic'])) {
$iD = $_POST['myId'];
$ticketsId = $_POST['ticketId'];
$username = $_POST['usersname'];
$mode = $_POST['mode'];
$location = $_POST['location'];
$sql = "INSERT INTO usedtickets(usedTic, ticketID, usersName, mode, locale) VALUES (?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "Error " . mysqli_stmt_error($stmt);
}
mysqli_stmt_bind_param($stmt, 'sssss', $iD, $ticketsId, $username, $mode, $location);
if (mysqli_stmt_execute($stmt)) {
$to = $_POST['usersemail'];
$subject = "Tickets Has Been Used";
$headers = array(
"MIME-version" => '1.0',
'Content-Type' => 'text/html;charset=UTF-8',
"From" => 'admin@wytemecury.com.ng',
'Reply-To' => "admin@wytemecury.com.ng"
);
$user = $_POST['usersname'];
$locale = $_POST['location'];
ob_start();
include('message_two.php');
$message = ob_get_contents();
ob_get_clean();
$send = mail($to, $subject, $message, $headers);
echo $send ? 'Mail is Sent' : 'We have A problem';
}
header('Location: delete.php?id=' . $iD);
}
$mysql = "SELECT * FROM usedTickets";
$query = mysqli_query($conn, $mysql);
$results_two = mysqli_fetch_all($query, MYSQLI_ASSOC);
if (isset($_POST['delete'])) {
$id = $_POST['myId'];
$mysql = "DELETE FROM usedTickets WHERE Id = $id";
if (mysqli_query($conn, $mysql)) {
header('Location: usedTickets.php');
} else {
echo "Error";
}
}
?>
<!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>WyteMecury Used Tickets</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>
<style>
#side {
height: 100vh;
position: fixed;
z-index: 1;
}
#second {
margin-left: 10rem;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-1 bg-primary shadow-sm" id="side">
<ul class="nav flex-column" style="margin-top: 7rem;">
<li class="nav-item">
<a href="adminHome.php" class="nav-link mb-5 mx-auto text-light"><svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" class="bi bi-house-fill" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L8 2.207l6.646 6.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.707 1.5Z" />
<path d="m8 3.293 6 6V13.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 13.5V9.293l6-6Z" />
</svg></a>
</li>
<li class="nav-item">
<a href="adminUser.php" class="nav-link mb-5 mx-auto text-light">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" class="bi bi-person-circle" viewBox="0 0 16 16">
<path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z" />
<path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z" />
</svg>
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link btn btn-light mx-auto ">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" 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>
</a>
</li>
<li class="nav-item mx-auto" style="margin-top: 20rem;">
<a href="adminProfile.php" class="btn btn-light">
<img src="image/user-solid.svg" width="30" height="30" alt="Profile Picture" class="rounded-circle">
</a>
</li>
</ul>
</div>
<div class="col-10" id="second">
<nav class="navbar navbar-expand-lg bg-white auto-hiding-navbar">
<div class="container">
<div class="navbar-brand">
<img src="templates/favicon.ico" alt="logo" width="35" height="35">
<span class="text-primary">Wyte</span>Mecury Admin
</div>
<div class="collapse navbar-collapse">
<div class="mx-auto search-form" style="width: 50%;">
<form action="search.php" method="get" class="d-lg-flex">
<input type="search" class="form-control rounded-pill" placeholder="Search Username" id="search" name="searchUsedTicket">
<button type="submit" class="btn btn-outline-success ms-2" name="search">Search</button>
</form>
</div>
<ul class="navbar-nav">
<li class="nav-item">
<a href="includes/LogoutAdmin.inc.php" class="btn btn-secondary">Logout <?php echo $_SESSION['adminName'] ?></a>
</li>
</ul>
</div>
</div>
</nav>
<div class="mt-5">
<h1 class="h1 mb-5">Hello <?php echo $_SESSION['adminName'] ?></h1>
<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>
<?php foreach ($results_two as $result) : ?>
<tr>
<th scope="row"><?php echo $result['ticketID'] ?></th>
<td id="username"><?php echo $result['usersName'] ?></td>
<td><?php echo $result['mode'] ?></td>
<td><?php echo $result['locale'] ?></td>
<td>
<form action="usedTickets.php" method="POST">
<input type="hidden" name="myId" value="<?php echo $result['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 Tickets</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>