-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpro_insert.php
30 lines (29 loc) · 894 Bytes
/
pro_insert.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
<?php
require 'vendor/autoload.php';
/*To insert a document in a collection*/
$mclient = new MongoDB\Client;
$msdb = $mclient->company;
$mobcollection = $msdb->pro;
$countinit=$mobcollection->count();
$id = $_GET['id'];
$proname = $_GET['proname'];
$country = $_GET['country'];
$client = $_GET['client'];
$start_date = $_GET['start_date'];
$insertOneResult = $mobcollection->insertOne(
['_id' => $id,'proname' => $proname,'country'=> $country,'client' => $client,'start_date' => $start_date]);
$countfin=$mobcollection->count();
if($countfin>$countinit)
{
echo '<script type="text/javascript">';
echo 'alert("Inserted Successfully!");';
echo 'window.location.href = "index.php";';
echo '</script>';
}
else
{
echo '<script type="text/javascript">';
echo 'alert("Could not Insert!");';
echo '</script>';
}
?>