-
Notifications
You must be signed in to change notification settings - Fork 2
/
delete_staff.php
36 lines (24 loc) · 1.04 KB
/
delete_staff.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
<?php
session_start();
require "vendor/autoload.php";
$staff_id = $_POST["staff_id"];
$role = $_POST["role"];
try {
$m = new MongoDB\Client("mongodb://vinay0410:Qh4tPdg3!@ds123725.mlab.com:23725/pizza");
$db = $m->pizza;
$collection = $db->users;
$collection->deleteOne(["_id" => new MongoDB\BSON\ObjectID($staff_id) ]);
} catch (MongoDB\Driver\Exception\ConnectionTimeoutException $e) {
echo json_encode(array('error' => True, 'msg' => "Couldn't Connect to Database"));
exit();
} catch (Exception $e) {
#die("Caught Exception failed to Connect".$e->getMessage()."\n");
echo json_encode(array('error' => True, 'msg' => $e->getMessage()));
exit();
}
if ($role == "chef") {
?>
<div id="success" class="alert alert-success" role="alert"><?php echo "Chef removed Successfully"; ?></div>
<?php } else { ?>
<div id="success" class="alert alert-success" role="alert"><?php echo "Delivery Staff removed Successfully"; ?></div>
<?php } ?>