-
Notifications
You must be signed in to change notification settings - Fork 0
/
system-admin-roles.php
77 lines (58 loc) · 1.58 KB
/
system-admin-roles.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
<?php include("system-header.php"); ?>
<!-- Start of content -->
<form id="commandForm" name="commandForm" method="POST">
<input type="text" id="newRole" name="newRole" value="" />
<input type="hidden" id="command" name="command" value="" />
<input type="hidden" id="role" name="role" value="" />
<button id="newButton" onclick="call('addRole');">Create</button>
</form>
<table width="100%" class="dataGrid">
<thead>
<tr>
<td>Role</td>
<td width='20px'></td>
</tr>
</thead>
<?php
function addRole() {
$role = $_POST['newRole'];
$qry = "INSERT INTO roles (roleid) VALUES ('$role')";
$result=mysql_query($qry);
if (! $result) {
die('Invalid query: ' . mysql_error());
}
}
function removeRole() {
$role = $_POST['role'];
$qry = "DELETE FROM roles WHERE roleid = '$role'";
$result=mysql_query($qry);
if (! $result) {
die('Invalid query: ' . mysql_error());
}
}
$qry = "SELECT * FROM roles";
$result=mysql_query($qry);
$rowNumber = 0;
//Check whether the query was successful or not
if($result) {
while($member = mysql_fetch_assoc($result)) {
echo "<tr><td>";
echo $member['roleid'];
echo "<td><img onclick='deleteRole(\"" . $member['roleid'] . "\")' src='images/delete.png' /></td>";
echo "</td></tr>";
}
} else {
die('Invalid query: ' . mysql_error());
}
?>
</table>
<script>
function deleteRole(role) {
if (confirm("Are you sure you want to delete the role (" + role + ") ?")) {
$("#role").val(role);
call("removeRole");
}
}
</script>
<!-- End of content -->
<?php include("system-footer.php"); ?>