-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathitem_delete.php
More file actions
26 lines (19 loc) · 822 Bytes
/
Copy pathitem_delete.php
File metadata and controls
26 lines (19 loc) · 822 Bytes
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
<?php
require "vendor/autoload.php";
$id = $_POST["id"];
try {
$m = new MongoDB\Client("mongodb://vinay0410:Qh4tPdg3!@ds123725.mlab.com:23725/pizza");
$db = $m->pizza;
$collection = $db->menu;
} catch (Exception $e) {
#die("Caught Exception failed to Connect".$e->getMessage()."\n");
echo json_encode(array('error' => True, 'msg' => "Couldn't Connect to Database"));
exit();
}
$item = $collection->findOne(['_id' => new MongoDB\BSON\ObjectID($id)] );
$result = $collection->deleteOne(['_id' => new MongoDB\BSON\ObjectID($id)] );
if (isset($item["path"])) {
unlink($item["path"]);
}
?>
<div id="success" class="alert alert-success" role="alert"><?php echo "Item Deleted Successfully"; ?></div>