-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
261 lines (225 loc) · 6.69 KB
/
add.php
File metadata and controls
261 lines (225 loc) · 6.69 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
if(!isset($_SESSION)){
session_start();
}
if(!isset($_SESSION["username"])){
header('Location: login.php');
exit();
}
$db = mysqli_connect('localhost', 'root', '', 'travel');
$username = $_SESSION["username"];
// Adding
if (isset($_POST['added'])) {
$username=$_SESSION['username'];
$place = mysqli_real_escape_string($db, $_POST['cit']);
$descr = mysqli_real_escape_string($db, $_POST['descr']);
$comm="";
$likes=0;
$query = "INSERT INTO data (username, place, descr, comm, likes)
VALUES('$username','$place','$descr','$comm',$likes)";
mysqli_query($db, $query);
header('location: home.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Add</title>
<style type="text/css">
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
font-size: 120%;
background: #F8F8FF;
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-size: cover;
}
.title{
text-align: center;
font-family: 'Arial, Helvetica, sans-serif';
letter-spacing: 0.2em;
font-size: 4em;
padding: 5px;
color: white;
}
.tagline{
text-align: center;
color: white;
font-family: 'Times New Roman';
letter-spacing: 0.2em;
font-size: 2em;
padding: 5px;
margin-bottom: 2%;
}
.header:after {
content: "";
display: table;
clear: both;
}
form {
width: 700px;
margin: 0px auto;
padding: 20px;
border: 1px solid #B0C4DE;
background: white;
border-radius: 0px 0px 10px 10px;
}
.input-group {
margin: 10px 0px 10px 0px;
}
.input-group label {
display: block;
text-align: left;
margin: 3px;
}
.input-group input {
height: 30px;
width: 93%;
padding: 5px 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid gray;
}
.header {
width: 30%;
margin: 50px auto 0px;
color: white;
background: #5F9EA0;
text-align: center;
border: 1px solid #B0C4DE;
border-bottom: none;
border-radius: 10px 10px 0px 0px;
padding: 20px;
}
input {
margin: 0;
border: none;
border-radius: 0;
width: 75%;
padding: 10px;
float: left;
font-size: 16px;
}
.btn {
padding: 10px;
font-size: 15px;
color: white;
background: #5F9EA0;
border: none;
border-radius: 5px;
cursor: pointer;
}
#btn2
{position:absolute;
padding: 10px;
font-size: 15px;
color: white;
background: #5F9EA0;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top:1%;
margin-left: 24%;
}
</style>
</head>
<body>
<h1 class="title">TRIP PLANNER</h1>
<div class="tagline">Plan your Trips based on Weather and Reviews</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBeCrcG5O2a3UmxHsCTMz3VgVu8Jz6jkqg&libraries=places&callback=initMap"
async defer></script>
<div id="map"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBeCrcG5O2a3UmxHsCTMz3VgVu8Jz6jkqg&libraries=places&callback=initMap"
async defer></script>
<script>
var geocoder;
var cityName;
var country;
var des;
var temp;
function home()
{window.location = "home.php";
}
function initMap()
{var infoWindow;
var options={
zoom:8,
center:{lat:13.0827,lng:80.2707}
}
geocoder = new google.maps.Geocoder();
var map=new google.maps.Map(document.getElementById("map"),options);
var autocomplete = new google.maps.places.Autocomplete(document.getElementById("city"),{ types: ['(cities)']});
google.maps.event.addListener(map,'click',function(event){
var apiCall='http://api.openweathermap.org/data/2.5/weather?lat=' + event.latLng.lat() + '&lon=' + event.latLng.lng() + '&appid=c3990fa461f26dbc4d72849f5b4b137a';
$.getJSON(apiCall,weatherCallBack);
function weatherCallBack(weatherData)
{ cityName=weatherData.name;
country=weatherData.sys.country;
des=weatherData.weather[0].description;
temp=weatherData.main.temp;
}
var marker=new google.maps.Marker({
position:event.latLng,
map:map
});
marker.addListener('click',function(event2){
var apiCall2='http://api.openweathermap.org/data/2.5/weather?lat=' + event2.latLng.lat() + '&lon=' + event2.latLng.lng() + '&appid=c3990fa461f26dbc4d72849f5b4b137a';
$.getJSON(apiCall2,weatherCallBack2);
function weatherCallBack2(weatherData1)
{
var temp=weatherData1.main.temp;
var cel1=temp-273.15;
var cel=cel1.toFixed(2);
infoWindow=new google.maps.InfoWindow({
content:'<div id="info"> Place: '+weatherData1.name+ '<br></br>'+ 'Country: '+ weatherData1.sys.country+ '<br></br>' + 'Current Weather: '+ weatherData1.weather[0].description + '<br></br>'+ 'Temperature: '+ cel + ' C'+ '</div>'
});
infoWindow.open(map,marker);
}
});
});
}
function displayWeather()
{document.getElementById("w").value="";
var inputCity=document.getElementById("city").value;
var apiCall='http://api.openweathermap.org/data/2.5/weather?q=' + inputCity + '&appid=c3990fa461f26dbc4d72849f5b4b137a';
$.getJSON(apiCall,weatherCallBack);
function weatherCallBack(weatherData)
{
var cityName=weatherData.name;
var country=weatherData.sys.country;
var des=weatherData.weather[0].description;
var temp=weatherData.main.temp;
var cel1=temp-273.15;
var cel=cel1.toFixed(2);
document.getElementById("w").innerHTML="Place: "+ cityName + "<br></br>" + ' Country: ' + country + '<br></br>' + 'Current Weather: '+ des+ '<br></br>' + 'Temperature: '+ cel + ' C';
}}
</script>
<div class="header">
<h2>ADD REVIEW</h2>
</div>
<form method="post" action="add.php">
<div class="input-group">
<label>City Name</label>
<input type="text" id="city" name="cit">
</div>
<div class="input-group">
<label>Description</label>
<input type="text" name="descr" >
</div>
<br>
<div class="input-group">
<button type="submit" class="btn" name="added">ADD</button>
</div>
</form>
<button id="btn2" onclick="home();">BACK TO HOME</button>
</body>
</html>