-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatepermissions.php
40 lines (29 loc) · 1.2 KB
/
updatepermissions.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
<?php
session_start();
require_once('Scripts/DBConnect.php');
require_once("Scripts/GeneralScripts.php");
checkLoginPermissions(2);
if($_SERVER['REQUEST_METHOD'] == "POST"){
// Get Posted Values
$StaffID = $_POST['StaffID'];
$UserManager = $_POST['User_Manager'] ?? '';
$ProductManager = $_POST['Product_Manager'] ?? '';
$CustomerManager = $_POST['Customer_Manager'] ?? '';
$OrderManager = $_POST['Order_Manager'] ?? '';
// Put Permission into an Array
$Permissions = [$UserManager, $ProductManager, $CustomerManager, $OrderManager];
// Remove all old permission for user
$sql = "DELETE FROM tblStaffPermissions
WHERE StaffID = $StaffID";
mysqli_query($db, $sql);
for($i = 0; $i < count($Permissions); $i++) {
if($Permissions[$i] != ''){
$sql = "INSERT INTO tblStaffPermissions (StaffID, PermissionID)
VALUES ($StaffID, $Permissions[$i])";
mysqli_query($db, $sql);
}
}
$message = "Permissions Updated.";
header("location: editstaff.php?UploadStatus=$message&StaffID=$StaffID");
}
?>