Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Assignment 6 Currency Converter</title>
- </head>
- <body>
- <form align="center" method="post" action="/currencyconvertor.php">
- <div id="box">
- <h2><center>Currency Converter</center></h2>
- <table>
- <tr>
- <td>
- Enter Amount:<input type="text" name="amount"><br>
- </td>
- </tr>
- <tr>
- <td>
- <br><center>From:<br><br><br>
- <input type="radio" id="canadian" name="firstCurrency" value="canadian">
- <label for="canadian"><img src="canadaFlag.jpg">Canadian</label><br>
- <input type="radio" id="american" name="firstCurrency" value="american">
- <label for="american"><img src="americanFlag.jpg" width="65" height="33">American</label><br>
- <input type="radio" id="euro" name="firstCurrency" value="euro">
- <label for="euro"><img src="euroFlag.jpg" width="85" height="55">Euro</label><br>
- <input type="radio" id="british" name="firstCurrency" value="british">
- <label for="british"><img src="englandFlag.jpg" width="65" height="45">Pound</label><br>
- <input type="radio" id="china" name="firstCurrency" value="china">
- <label for="china"><img src="chineseFlag.png" width="115" height="95">Yuan</label><br>
- </td>
- </tr>
- <tr>
- <td>
- <br><center>To:<br><br><br>
- <input type="radio" id="canadian" name="secondCurrency" value="canadian">
- <label for="canadian"><img src="canadaFlag.jpg">Canadian</label><br>
- <input type="radio" id="american" name="secondCurrency" value="american">
- <label for="american"><img src="americanFlag.jpg" width="65" height="33">American</label><br>
- <input type="radio" id="euro" name="secondCurrency" value="euro">
- <label for="euro"><img src="euroFlag.jpg" width="85" height="55">Euro</label><br>
- <input type="radio" id="british" name="secondCurrency" value="british">
- <label for="british"><img src="englandFlag.jpg" width="65" height="45">Pound</label><br>
- <input type="radio" id="china" name="secondCurrency" value="china">
- <label for="china"><img src="chineseFlag.png" width="115" height="95">Yuan</label><br>
- </td>
- </tr>
- <tr>
- <td><center><br>
- <input type='submit' name='submit' value='Convert'></center>
- </td>
- </tr>
- </table>
- </form>
- <?php
- function conversion($amount, $firstCurrency, $secondCurrency) {
- if($firstCurrency == "canadian" AND $secondCurrency == "american") {
- $convertedAmount = $amount * 0.80;
- return $convertedAmount;
- echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
- echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="americanFlag.jpg" width:="65" height="33"></p>';
- }
- if($firstCurrency == "canadian" AND $secondCurrency == "euro") {
- $convertedAmount = $amount * 0.67;
- return $convertedAmount;
- echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
- echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="euroFlag.jpg" width="85" height="55"></p>';
- }
- if($firstCurrency == "canadian" AND $secondCurrency == "british") {
- $convertedAmount = $amount * 0.58;
- return $convertedAmount;
- echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
- echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="englandFlag.jpg" width="65" height="45"</p>';
- }
- if($firstCurrency == "canadian" AND $secondCurrency == "china") {
- $convertedAmount = $amount * 5.21;
- return $convertedAmount;
- echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
- echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="chineseFlag.jpg" width="115" height="95"</p>';
- }
- }
- if (isset($_POST['submit'])){
- $amount = htmlspecialchars($_POST['amount']);
- $firstCurrency = htmlspecialchars($_POST['firstCurrency']);
- $secondCurrency = htmlspecialchars($_POST['secondCurrency']);
- conversion($amount, $firstCurrency, $secondCurrency);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement