AkinaZEW
Configuration Manager
LEVEL 1
200 XP
In this tutorial we will create a Basic Money Converter using PHP. This code will convert the given value to a specific currency value. The code use a PHP POST to convert the given value base on the currency options by doing the arithmetic formulas. This is a user-friendly kind of program feel free to modify it.
We will be using PHP as a scripting language and interpreter that is used primarily on any webserver including xamp, wamp, etc. It is being use to any famous websites and it has a modern technology that can easily be use by the next generation.
Getting Started:
First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.
And, this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
Creating The Interface
This is where we will create a simple form for our application. To create the forms simply copy and write it into your text editor, then save it as index.php.
Creating the Main Function
This code contains the main function of the application. This code will convert the money value when the button is clicked. To make this just copy and write these block of codes below inside the text editor, then save it as convert.php
There you have it we successfully created Basic Money Converter using PHP. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Download
We will be using PHP as a scripting language and interpreter that is used primarily on any webserver including xamp, wamp, etc. It is being use to any famous websites and it has a modern technology that can easily be use by the next generation.
Getting Started:
First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.
And, this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
Creating The Interface
This is where we will create a simple form for our application. To create the forms simply copy and write it into your text editor, then save it as index.php.
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodster</a>
- </div>
- </nav>
- <div class="col-md-3"></div>
- <div class="col-md-6 well">
- <h3 class="text-primary">PHP - Basic Money Converter</h3>
- <hr style="border-top:1px dotted #000;"/>
- <div class="col-md-3"></div>
- <div class="col-md-6">
- <form method="POST" action="">
- <div class="form-inline">
- <select name="val" class="form-control">
- <option value="PHP">PHP</option>
- <option value="USD">USD</option>
- </select>
- <input class="form-control" type="number" name="digit"/>
- </div>
- <br />
- <div class="form-inline">
- <label>Select Currency: </label>
- <select name="currency" required="required" class="form-control">
- <option value="">Select an option</option>
- <option value="USD">USD</option>
- <option value="Euro">Euro</option>
- <option value="PHP">PHP</option>
- <option value="Japanese Yen">Japanese Yen</option>
- </select>
- <br /><br />
- <center><button type="submit" name="convert" class="btn btn-primary form-control" style="width:30%;">Convert</button></center>
- <br />
- </div>
- <?php
require
'convert.php'
?>
- </form>
- </div>
- </div>
- </body>
- </html>
Creating the Main Function
This code contains the main function of the application. This code will convert the money value when the button is clicked. To make this just copy and write these block of codes below inside the text editor, then save it as convert.php
- <?php
- if
(
ISSET
(
$_POST
[
'convert'
]
)
)
{
- $val
=
$_POST
[
'val'
]
;
- $digit
=
$_POST
[
'digit'
]
;
- $currency
=
$_POST
[
'currency'
]
;
- if
(
$val
==
"PHP"
&&
$currency
==
"USD"
)
{
- $output
=
$digit
*
51.52
;
- echo
"<center><label class='text-success' style='font-size:25px;'>$"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"PHP"
&&
$currency
==
"Euro"
)
{
- $output
=
$digit
*
63.62
;
- echo
"<center><label class='text-success' style='font-size:25px;'>€"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"PHP"
&&
$currency
==
"PHP"
)
{
- $output
=
$digit
;
- echo
"<center><label class='text-success' style='font-size:25px;'>₱"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"PHP"
&&
$currency
==
"Japanese Yen"
)
{
- $output
=
$digit
*
0.47
;
- echo
"<center><label class='text-success' style='font-size:25px;'>¥"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"USD"
&&
$currency
==
"USD"
)
{
- $output
=
$digit
;
- echo
"<center><label class='text-success' style='font-size:25px;'>$"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"USD"
&&
$currency
==
"Euro"
)
{
- $output
=
$digit
*
0.89
;
- echo
"<center><label class='text-success' style='font-size:25px;'>€"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"USD"
&&
$currency
==
"PHP"
)
{
- $output
=
$digit
/
51.52
;
- echo
"<center><label class='text-success' style='font-size:25px;'>₱"
.
$output
.
"</label></center>"
;
- }
else
if
(
$val
==
"USD"
&&
$currency
==
"Japanese Yen"
)
{
- $output
=
$digit
*
107.72
;
- echo
"<center><label class='text-success' style='font-size:25px;'>¥"
.
$output
.
"</label></center>"
;
- }
- }
- ?>
There you have it we successfully created Basic Money Converter using PHP. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Download
You must upgrade your account or reply in the thread to view the hidden content.