Skip to main content

Build Currency Converter Using PHP, MYSQL WITH DEMO

Currency Converter is used to convert one currency into other currency. Previously for currency conversion, we are using Google Finance API. But now Google Finance API is deprecated and no longer supported by Google.

So it means no future development, and no bug fixes will be done in Google finance API. Also according to the latest update, Google Finance API is stopped functioning.

All the website that is using Google Finance API should be a switch to the alternative of Google Finance API

In this post, we use the alternative of Google Finance API and create a currency converter system in PHP.

For creating the currency converter we are using API . provides two types of API for the currency conversion.
First one is the free version it has some limitation like we can call API only certain times in hours, other is the premium version that has no limitations like API call limit in the hour etc API integration is very easy and simple and it returns the response in the JSON and JSONP Data format. We can easily handle response according to our requirements.

In this tutorial we are using the free version of the API, the free version has some limitation. We have listed down the limitation below.

Some Of The Limitations OF Using Free version of API

  • Conversion Pairs per Request Is : 2
  • Number of Requests per Hour: 100
  • Date Range in History: 8 Days
  • Allowed Back in History: 1 Year(s)

So now we can move to the coding parts:

File structure for currency converter system is following.

index.php :- Currency converter form
currency-converter.php :- Php file that handle logic for Converting currency into other currency
script.js :- JavaScript file Handle ajax request
db-connection.php :- This file contains database connection details

You can see the live demo of the currency converter and also download the code , link is given below at the end of this tutorial

Step 1: Create currency_list table and insert some record in currency_list table

Step 2: Create currency converter form

Create index.php file and also create currency converter form to select From currency , To currency and input for amount to convert

Step 3: Create script.js file

In the script.js file, we create a function convertCurrency().
When a currency converter form is submitted convertCurrency() function will make ajax request to the currency-converter.php to handle server-side processing for currency conversion.

Step 4: Create currency-converter.php file

In the currency-converter.php file, we get from currency input, to currency input, amount, after that we pass all the input to convertCurrency() function and finally it makes the request to API and it returns the converted amount in JSON format.

Conclusion :- In this tutorial we learn how to create currency converter system using php.If you found any mistake in this tutorial please comment below.


Recomended Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.