-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
37 lines (19 loc) · 888 Bytes
/
main.php
File metadata and controls
37 lines (19 loc) · 888 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
27
28
29
30
31
32
33
34
35
36
37
<?php
if (isset($_POST['sub']))
{
$city = $_POST['city'];
// $country = $_POST['cc'];
$url="http://api.openweathermap.org/data/2.5/weather?q=".$city."&units=metric&cnt=7&lang=en&appid=9d170c1ab1e342e5efb1f239653057de";
$json=file_get_contents($url);
$data=json_decode($json,true);
echo "<h2>Current Temperature in " . $city . " is :<button class='btn btn-success'>" . $data['main']['temp'] . "° Celcius</button></h2>";
echo "<h2>Wind Speed is :<u>" . $data['wind']['speed'] . "</u> KMPH</h2>";
echo "<h2>Humidity is :<u>" . $data['main']['humidity'] . "</u> %</h2>";
echo "<h2>Weather condition:<u>" . $data['weather'][0]['main'] . "</u>";
echo "<img src='http://openweathermap.org/img/w/" .$data['weather'][0]['icon']. ".png' width='90' height='90'></h2>";
}
else
{
echo "Oops something went wrong !! ;(";
}
?>