-
Notifications
You must be signed in to change notification settings - Fork 3
/
insert.php
55 lines (50 loc) · 1.3 KB
/
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
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
<!DOCTYPE html>
<html>
<head>
<title>returnTrue</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/style.css" rel="stylesheet" media="screen">
</head>
<body>
<div class = "row" style = "height: 100px">
</div>
<div class = "row">
<div class = "col-md-6 col-md-offset-3">
<?php
$m = new MongoClient();
$db = $m -> hindu;
$collection = $db -> chennai;
$name = $_POST["name"];
$content = $_POST["content"];
$city = $_POST["city"];
$locality = $_POST["locality"];
$range = strtolower($_POST["range"]);
$rating = $_POST["rating"];
$category = $_POST["category"];
$phone = $_POST["phone"];
switch($range)
{
case "high": $range = 3;
break;
case "medium": $range = 2;
break;
case "low": $range = 1;
break;
}
$classified = array("name" => $name, "content" => $content, "city" => $city, "locality" => $locality, "range" => $range, "rating" => $rating, "phone" => $phone, "category" => $category, "datePosted" => new MongoDate());
try
{
$collection -> insert($classified);
echo "Success!";
header("Location:insertform.php");
}
catch(MongoCursorException $e)
{
echo "Classified already exists!";
}
?>
</div>
</div>
</body>
</html>