1<?php
2 /////for current update currency using api/////
3 $curl = curl_init();
4curl_setopt_array($curl, array(
5 CURLOPT_URL => "https://api.exchangeratesapi.io/latest?base=USD",
6 CURLOPT_RETURNTRANSFER => true,
7 CURLOPT_ENCODING => "",
8 CURLOPT_MAXREDIRS => 10,
9 CURLOPT_TIMEOUT => 30,
10 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
11 CURLOPT_CUSTOMREQUEST => "GET",
12 CURLOPT_POSTFIELDS => "{\n\t\"QuantityOnHand\":1,\n\t\"ReOrderPoint\":1,\n\t\"QuantityAsOfDate\":\"2018-03-01\"\n}",
13 CURLOPT_HTTPHEADER => array(
14 "cache-control: no-cache",
15 "postman-token: f8326c98-2bb7-a466-6f5e-cb8bfc5421d0"
16 ),
17));
18
19$response = curl_exec($curl);
20$err = curl_error($curl);
21
22curl_close($curl);
23
24if ($err) {
25 echo "cURL Error #:" . $err;
26} else {
27 $response;
28 $response= json_decode($response,true);
29 $CAD= $response['rates']['CAD'];
30 $AUD= $response['rates']['AUD'];
31
32 $GBP= $response['rates']['GBP'];
33
34
35
36
37
38 // echo"<pre>";
39 // print_r($response);
40 // echo"</pre>";
41
42?>
1<html>
2<head>
3<style>
4 #box
5 {
6 width:350px;
7 height:270px;
8 margin:0px auto;
9 border:2px solid black;
10 }
11 h2{
12 text-align: center;
13 }
14 table{
15 margin:0px auto;
16 }
17</style>
18</head>
19
20<body>
21
22<form align="center" action="currencyconvertor.php" method="post">
23
24<div id="box">
25<h2><center>Currency Converter</center></h2>
26<table>
27 <tr>
28 <td>
29 Enter Amount:<input type="text" name="amount"><br>
30 </td>
31</tr>
32<tr>
33<td>
34 <br><center>From:<select name='cur1'>
35 <option value="AUD">Australian Dollar(AUD)</option>
36 <option value="USD" selected>US Dollar(USD)</option>
37 </select>
38</td>
39</tr>
40<tr>
41 <td>
42 <br><center>To:<select name='cur2'>
43 <option value="INR" selected >Indian Rupee(INR)</option>
44 <option value="JPY">Japanese Yen(JPY)</option>
45 <option value="PHP">Philippine Peso(PHP)</option>
46
47 </select>
48</td>
49</tr>
50<tr>
51<td><center><br>
52<input type='submit' name='submit' value="CovertNow"></center>
53</td>
54</tr>
55</table>
56</form>
57<?php
58if(isset($_POST['submit'])){
59
60$amount = $_POST['amount'];
61$cur1 = $_POST['cur1'];
62$cur2 = $_POST['cur2'];
63
64if($cur1=="AUD" AND $cur2=="JPY"){
65echo "<center><b>Your Converted Amount is:</b><br></center>";
66echo "<center>" . $amount*82.463 . "</center>";
67}
68
69if($cur1=="AUD" AND $cur2=="INR"){
70echo "<center><b>Your Converted Amount is:</b><br></center>";
71echo "<center>" . $amount* 51.09 . "</center>";
72}
73
74if($cur1=="AUD" AND $cur2=="PHP"){
75echo "<center><b>Your Converted Amount is:</b><br></center>";
76echo "<center>" . $amount* 37.15 . "</center>";
77}
78
79if($cur1=="USD" AND $cur2=="JPY"){
80echo "<center><b>Your Converted Amount is:</b><br></center>";
81echo "<center>" . $amount* 109.49 . "</center>";
82}
83
84if($cur1=="USD" AND $cur2=="INR"){
85echo "<center><b>Your Converted Amount is:</b><br></center>";
86echo "<center>" . $amount* 67.83 . "</center>";
87}
88
89if($cur1=="USD" AND $cur2=="PHP"){
90echo "<center><b>Your Converted Amount is:</b><br></center>";
91echo "<center>" . $amount*49.32 . "</center>";
92}
93
94
95}
96
97?>
98
99</body>
100</html>