-
Notifications
You must be signed in to change notification settings - Fork 11
/
dustbin_on_demand.php
193 lines (157 loc) · 4.49 KB
/
dustbin_on_demand.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
include_once 'includes/dbh.inc.php';
session_start();
$current_user="superuser";
if(isset($_SESSION["current_user"])){
$current_user=$_SESSION["current_user"];
}
if(isset($_POST["submit"])){
$username = $current_user;
$order_location = mysqli_real_escape_string($conn,$_POST['order_location']);
$delivery_date = mysqli_real_escape_string($conn,$_POST['delivery_date']);
$type_waste = mysqli_real_escape_string($conn,$_POST['type_waste']);
$size_bin = mysqli_real_escape_string($conn,$_POST['size_bin']);
$number_bin = mysqli_real_escape_string($conn,$_POST['number_bin']);
$amt=0;
$garbageamt=0;
$stat='pending';
$order_date=date("Y-m-d h:i:s");
$location = str_replace(' ' ,'+', $order_location);
//echo $location;
//echo $location;
//echo "<script> alert('success'); </script>";
echo "<script src=\"https://maps.googleapis.com/maps/api/js?key=AIzaSyDh6azLDLezjjQELjrA9aHVlOGUwC6Vk2M\">
</script>";
$response = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.$location.'&key=AIzaSyAWXfT_MtWlzrJbVNI4zq-0f0hq4LHMzHw', false);
echo $response;
$resp = json_decode($response, true);
if($resp['status']=='OK'){
$lat = $resp['results'][0]['geometry']['location']['lat'];
$lng = $resp['results'][0]['geometry']['location']['lng'];
//echo "<script> alert('success1'); </script>";
$sql="INSERT INTO order_details(user_uid,lat,lng,orderdate,deliverydate,typeofbin,sizeofbin,noofbin,returnamount,orderstatus,garbageamount) VALUES ('$username','$lat','$lng','$order_date','$delivery_date','$type_waste','$size_bin','$number_bin','$amt','$stat','$garbageamt')";
//echo $sql;
mysqli_query($conn,$sql);
$sqlorder = "select max(orderno) from order_details;";
$result = $conn->query($sqlorder);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$temp = $row['max(orderno)'];
}
} else {
echo "0 results";
}
echo "<script> alert('Order Placed Successfully,Your order number is $temp'); </script>";
echo "<script> window.location.replace('index.php'); </script>";
}
}
?>
<html>
<head>
<title>DustbinOnDemand</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: black;
/*#93c572;*/
}
* {
box-sizing: border-box;
}
.container {
padding: 12px;
background-color: white;
}
/* Full-width input fields */
input[type=text], input[type=password] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
.full {
background-color: #ddd;
outline: none;
}
.half{
float: left;
width: 50%;
padding: 1%;
}
/* Overwrite default styles of hr */
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
h1{
text-align: center;
}
.orderbtn {
background-color: #4CAF50;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.orderbtn:hover {
opacity: 1;
}
.inputtype{
width: 20vw;
background-color: #ddd;
padding: 8px 10px;
border: none;
cursor: pointer;
}
a {
color: dodgerblue;
}
.signin {
background-color: #f1f1f1;
text-align: center;
}
</style>
</head>
<body>
<form class="signup-form" method="POST" actio>
<div class="container">
<h1>Get dustbin On Demand</h1>
<hr>
<label><b>Location</b></label>
<input type="text" placeholder="Location" class="full" name="order_location" required>
<div style="float:left;position:absolute;width:50%;">
<label><b>Delivery date</b></label>
<input type="date" placeholder="Delivery date" name="delivery_date" class="inputtype" required>
</div>
<div style="float:right;position:relative;width:50%;">
<label><b>Type of Waste</b></label>
<select class="inputtype" name="type_waste">
<option value="plastic">Plastic</option>
<option value="paper">Paper</option>
</select>
</div>
<br><br><br><br>
<div style="float:left;position:absolute;width:50%;">
<label><b>Size of bin</b></label>
<select class="inputtype" name="size_bin">
<option value="100">100L</option>
<option value="200">200L</option>
</select>
</div>
<div style="float:right;position:relative;width:50%;">
<label><b>Number of Bins</b></label>
<input type="number" placeholder="No. of Bins" name="number_bin" class="inputtype" required>
</div>
<br><br>
<button type="submit" class="orderbtn" name="submit">Place Order</button>
</div>
</form>
</body>
</html>