Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Learn How to Create a Currency Converter Using PHP

currency-converter

A Currency Converter is a calculator that converts the value or quantity of one currency into the relative values or quantities of other currencies. For example, if you lived in the US and were traveling to another country, you would need to know the per dollar exchange rate for the currency of the country you were visiting. You would need to know the dollar- euro conversion, if you were traveling to certain parts of Europe, the dollar-pound conversion if you were in traveling in the United Kingdom, the dollar-yen conversion if you were traveling in Japan, the Canadian dollar – U.S. dollar conversion if you were traveling in Canada or the Swiss francs-dollar conversion if you were traveling in Switzerland.

A currency Converter stores the most recent market valuations of the world’s currencies, which allows individuals to compare the value of one currency against those of others in the database.

In this article, we are going to build a simple currency calculator which is based on PHP as well as we are going to use the if condition and the basic html syntax. For this we need XAMPP or WAMPP.

Steps for installing Xampp: –
1. You have to visit the following link https://www.apachefriends.org/index.html Once you open the link, you have to download the installation file according to your operating system. Once the installation is finished, you have to go your installation drive ( I used the C drive) and click on Xampp folder. After clicking on XAMPP, you will be able to see multiple folders, click on htdocs.

In this folder, you can add your code. I attached the screen-shot, have a look:
htdocs
2. Now, we have to create a folder inside the htdocs named as converter. After that we have to create a file named currencyconvertor.php inside the converter folder. You can see the attached screen-shot:
converter

Steps for Implementation:
1. Now its time to start our coding part. Firstly we are going to design our form using basic html element after that we want to add the data in table format so I added table tag inside form. You will use the code stated below:






Currency Converter

Enter Amount:

From:

To:

This will be your output:
currency-converter

2. Now after designing the form, we have to write a logic for currency converter. We used the IF condition as well as we used isset (). It is used to check whether a variable is set or not. If a variable is already unset with unset() function, it will no longer be set. The isset() function returns false if testing variable contains a NULL value.

After that, we are going to use $_POST(). The PHP provides $_POST associative array to access all the sent information using POST method. I attached the code below:

Your Converted Amount is:
"; echo "
" . $amount*82.463 . "
"; } if($cur1=="AUD" AND $cur2=="INR"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 51.09 . "
"; } if($cur1=="AUD" AND $cur2=="PHP"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 37.15 . "
"; } if($cur1=="USD" AND $cur2=="JPY"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 109.49 . "
"; } if($cur1=="USD" AND $cur2=="INR"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 67.83 . "
"; } if($cur1=="USD" AND $cur2=="PHP"){ echo "
Your Converted Amount is:
"; echo "
" . $amount*49.32 . "
"; } }

3. Now its time to add some CSS into your project so we are going to add the CSS part in header part using the style tag.

After adding html, css and php, your code look like this:


Currency Converter

Enter Amount:

From:

To:

Your Converted Amount is:
"; echo "
" . $amount*82.463 . "
"; } if($cur1=="AUD" AND $cur2=="INR"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 51.09 . "
"; } if($cur1=="AUD" AND $cur2=="PHP"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 37.15 . "
"; } if($cur1=="USD" AND $cur2=="JPY"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 109.49 . "
"; } if($cur1=="USD" AND $cur2=="INR"){ echo "
Your Converted Amount is:
"; echo "
" . $amount* 67.83 . "
"; } if($cur1=="USD" AND $cur2=="PHP"){ echo "
Your Converted Amount is:
"; echo "
" . $amount*49.32 . "
"; } } ?>

currency-converter-page
convert-currency
I hope this has been helpful for you guys in understanding a how to create a currency convertor using php.. Goodluck!

The post Learn How to Create a Currency Converter Using PHP appeared first on Eduonix.com | Blog.



This post first appeared on How And When Should You Use HBase NoSQL DB, please read the originial post: here

Share the post

Learn How to Create a Currency Converter Using PHP

×

Subscribe to How And When Should You Use Hbase Nosql Db

Get updates delivered right to your inbox!

Thank you for your subscription

×