-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinvites.php
executable file
·128 lines (110 loc) · 3.23 KB
/
invites.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
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Invite codes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script type="text/javascript">
function confirmcreate(){
$.ajax({
url: "actions/generatecode.php",
type: "GET",
success: function(){
swal.fire({
position: "top-end",
type: "success",
title: "Invite code created",
showConfirmButton: false,
timer: 1200
});
setTimeout(function(){
location.reload();
}, 700)
},
error: function(xhr,ajaxOptions,thrownError){
swal.fire({
position: "top-end",
type: "error",
title: "An error occured",
showConfirmButton: false,
timer: 1100
});
}
});
}
// Check if deleted and then show result
var deleteornot = "<?php echo $_SESSION['deletedinv'];?>";
if( deleteornot == "1") {
swal.fire({
position: "top-end",
type: "success",
title: "Deleted successfully",
showConfirmButton: false,
timer: 1200
});
} else if (deleteornot == "0") {
swal.fire({
position: "top-end",
type: "error",
title: "Error Deleting",
showConfirmButton: false,
timer: 1200
});
}
<?php
//unset the variable
unset($_SESSION['deletedinv']);
?>
</script>
</head>
<body>
<?php
include 'navigator.php';
?>
<table class="table table-striped">
<div class="table responsive">
<thead>
<tr>
<th>#1</th>
<th>Used</th>
<th>Code</th>
<th>User</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- <div id="invites"> -->
<?php
if ($_SESSION["username"] == "admin") {
// Include config file
require_once "config.php";
$query = $conn->prepare("SELECT * FROM invite");
$query->execute();
$result= $query->fetchAll();
//loop on earch row
foreach($result as $row) {
echo "<td id=\"id\">" . $row["id"]. "</td>";
echo "<td id=\"used\">" . $row["used"]. "</td>";
echo "<td id=\"code\">". $row["code"]. "</td>";
echo "<td id=\"ownedby\">" . $row["ownedby"]. "</td>";
echo "<td><a href='actions/delete.php?id=" .$row['code']."'><button type=\"button\" class=\"btn btn-danger\">Delete</button></a></td>";
echo "</tr>";
}
}else{
header("Location: index.php");
}
?>
<!-- </div> -->
</tbody>
<a href="javascript:void(0);" onclick="confirmcreate()"<button style="float:right" type="button" class="btn btn-success">Generate</button> </a>
</div>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
</body>
</html>