php currency converter script

<?php
  /////for current update currency using api/////
  $curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.exchangeratesapi.io/latest?base=USD",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "{\n\t\"QuantityOnHand\":1,\n\t\"ReOrderPoint\":1,\n\t\"QuantityAsOfDate\":\"2018-03-01\"\n}",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "postman-token: f8326c98-2bb7-a466-6f5e-cb8bfc5421d0"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
 $response;
  $response= json_decode($response,true);
 $CAD= $response['rates']['CAD'];
 $AUD= $response['rates']['AUD'];
   
   $GBP= $response['rates']['GBP'];
  
 



  // echo"<pre>";
  // print_r($response);
  // echo"</pre>";
 
?>

4.33
9
Leamsi 100 points

                                    &lt;html&gt;
&lt;head&gt;
&lt;style&gt;
	#box
	{
		width:350px;
		height:270px;
		margin:0px auto;
		border:2px solid black;
	}
	h2{
		text-align: center;
	}
	table{
		margin:0px auto;
	}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;form align=&quot;center&quot; action=&quot;currencyconvertor.php&quot; method=&quot;post&quot;&gt;

&lt;div id=&quot;box&quot;&gt;
&lt;h2&gt;&lt;center&gt;Currency Converter&lt;/center&gt;&lt;/h2&gt;
&lt;table&gt;
	&lt;tr&gt;
	&lt;td&gt;
		Enter Amount:&lt;input type=&quot;text&quot; name=&quot;amount&quot;&gt;&lt;br&gt;
	&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
	&lt;br&gt;&lt;center&gt;From:&lt;select name='cur1'&gt;
	 &lt;option value=&quot;AUD&quot;&gt;Australian Dollar(AUD)&lt;/option&gt;
	 &lt;option value=&quot;USD&quot; selected&gt;US Dollar(USD)&lt;/option&gt;
	 &lt;/select&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
	&lt;br&gt;&lt;center&gt;To:&lt;select name='cur2'&gt;
	 &lt;option value=&quot;INR&quot; selected &gt;Indian Rupee(INR)&lt;/option&gt;
	 &lt;option value=&quot;JPY&quot;&gt;Japanese Yen(JPY)&lt;/option&gt;
	 &lt;option value=&quot;PHP&quot;&gt;Philippine Peso(PHP)&lt;/option&gt;
	
	&lt;/select&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;center&gt;&lt;br&gt;
&lt;input type='submit' name='submit' value=&quot;CovertNow&quot;&gt;&lt;/center&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;?php
if(isset($_POST['submit'])){
	
$amount = $_POST['amount'];
$cur1 = $_POST['cur1'];
$cur2 = $_POST['cur2'];

if($cur1==&quot;AUD&quot; AND $cur2==&quot;JPY&quot;){
echo &quot;&lt;center&gt;&lt;b&gt;Your Converted Amount is:&lt;/b&gt;&lt;br&gt;&lt;/center&gt;&quot;;
echo &quot;&lt;center&gt;&quot; . $amount*82.463 . &quot;&lt;/center&gt;&quot;;
}

if($cur1==&quot;AUD&quot; AND $cur2==&quot;INR&quot;){
echo &quot;&lt;center&gt;&lt;b&gt;Your Converted Amount is:&lt;/b&gt;&lt;br&gt;&lt;/center&gt;&quot;;
echo &quot;&lt;center&gt;&quot; . $amount* 51.09 . &quot;&lt;/center&gt;&quot;;
}

if($cur1==&quot;AUD&quot; AND $cur2==&quot;PHP&quot;){
echo &quot;&lt;center&gt;&lt;b&gt;Your Converted Amount is:&lt;/b&gt;&lt;br&gt;&lt;/center&gt;&quot;;
echo &quot;&lt;center&gt;&quot; . $amount* 37.15 . &quot;&lt;/center&gt;&quot;;
}

if($cur1==&quot;USD&quot; AND $cur2==&quot;JPY&quot;){
echo &quot;&lt;center&gt;&lt;b&gt;Your Converted Amount is:&lt;/b&gt;&lt;br&gt;&lt;/center&gt;&quot;;
echo &quot;&lt;center&gt;&quot; . $amount* 109.49 . &quot;&lt;/center&gt;&quot;;
}

if($cur1==&quot;USD&quot; AND $cur2==&quot;INR&quot;){
echo &quot;&lt;center&gt;&lt;b&gt;Your Converted Amount is:&lt;/b&gt;&lt;br&gt;&lt;/center&gt;&quot;;
echo &quot;&lt;center&gt;&quot; . $amount* 67.83 . &quot;&lt;/center&gt;&quot;;
}

if($cur1==&quot;USD&quot; AND $cur2==&quot;PHP&quot;){
echo &quot;&lt;center&gt;&lt;b&gt;Your Converted Amount is:&lt;/b&gt;&lt;br&gt;&lt;/center&gt;&quot;;
echo &quot;&lt;center&gt;&quot; . $amount*49.32  . &quot;&lt;/center&gt;&quot;;
}


}

?&gt;

&lt;/body&gt;
&lt;/html&gt;

4.33 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
dollar currency format php convert number in currency in php currency converter php source code php php currency converter how to create a currency converter in php php money converter how to integrate currency in a php script php currency converter code format number to currency in php currency converter in php source code currency converter in php hoe to create currency exchange in php format currency php PHP get currency symbol from currency code php free currency converter php currency converter script how to add currency converter in a php website how to change currency convert on php Currency converter script PHP currency convert in php currency converter php string to currency php converting to any currency logic exchange rate php CHANGING CURRENCY PHP money convertor in php currency converter using php and sql currency converter in php php to currency format php to currency php currency format php currency conversion php format number to currency create currency converter in php php number to currency php convert to currency format php php currency converter php convert to currency convert currency in php currency symbol conversion php automatic currency conversion in php php currency numeric code free currency converter php currency php currency converter function php currency converter with database in php how to create currency converter php money exchange php script currency to number php currency conversion in php currency converter php code best Currency exchange script php format currency in php php currency php convert currency to number php currency code convert currency php number format for currency in php currency format dollar to number in php how to format number into currency php php convert currency convert euro to dollar in php language convert euro to dollar in php language&acute; currency convertor in php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source