Advertisement
Guest User

Untitled

a guest
Mar 15th, 2021
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Assignment 6 Currency Converter</title>
  4. </head>
  5.  
  6. <body>
  7.  
  8. <form align="center" method="post" action="/currencyconvertor.php">
  9.  
  10. <div id="box">
  11. <h2><center>Currency Converter</center></h2>
  12. <table>
  13.  
  14. <tr>
  15. <td>
  16. Enter Amount:<input type="text" name="amount"><br>
  17. </td>
  18. </tr>
  19.  
  20. <tr>
  21. <td>
  22. <br><center>From:<br><br><br>
  23. <input type="radio" id="canadian" name="firstCurrency" value="canadian">
  24. <label for="canadian"><img src="canadaFlag.jpg">Canadian</label><br>
  25. <input type="radio" id="american" name="firstCurrency" value="american">
  26. <label for="american"><img src="americanFlag.jpg" width="65" height="33">American</label><br>
  27. <input type="radio" id="euro" name="firstCurrency" value="euro">
  28. <label for="euro"><img src="euroFlag.jpg" width="85" height="55">Euro</label><br>
  29. <input type="radio" id="british" name="firstCurrency" value="british">
  30. <label for="british"><img src="englandFlag.jpg" width="65" height="45">Pound</label><br>
  31. <input type="radio" id="china" name="firstCurrency" value="china">
  32. <label for="china"><img src="chineseFlag.png" width="115" height="95">Yuan</label><br>
  33. </td>
  34. </tr>
  35.  
  36. <tr>
  37. <td>
  38. <br><center>To:<br><br><br>
  39. <input type="radio" id="canadian" name="secondCurrency" value="canadian">
  40. <label for="canadian"><img src="canadaFlag.jpg">Canadian</label><br>
  41. <input type="radio" id="american" name="secondCurrency" value="american">
  42. <label for="american"><img src="americanFlag.jpg" width="65" height="33">American</label><br>
  43. <input type="radio" id="euro" name="secondCurrency" value="euro">
  44. <label for="euro"><img src="euroFlag.jpg" width="85" height="55">Euro</label><br>
  45. <input type="radio" id="british" name="secondCurrency" value="british">
  46. <label for="british"><img src="englandFlag.jpg" width="65" height="45">Pound</label><br>
  47. <input type="radio" id="china" name="secondCurrency" value="china">
  48. <label for="china"><img src="chineseFlag.png" width="115" height="95">Yuan</label><br>
  49. </td>
  50. </tr>
  51.  
  52. <tr>
  53. <td><center><br>
  54. <input type='submit' name='submit' value='Convert'></center>
  55. </td>
  56. </tr>
  57. </table>
  58. </form>
  59.  
  60. <?php
  61.  
  62.  
  63. function conversion($amount, $firstCurrency, $secondCurrency) {
  64.  
  65. if($firstCurrency == "canadian" AND $secondCurrency == "american") {
  66. $convertedAmount = $amount * 0.80;
  67. return $convertedAmount;
  68. echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
  69. echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="americanFlag.jpg" width:="65" height="33"></p>';
  70. }
  71.  
  72. if($firstCurrency == "canadian" AND $secondCurrency == "euro") {
  73. $convertedAmount = $amount * 0.67;
  74. return $convertedAmount;
  75. echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
  76. echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="euroFlag.jpg" width="85" height="55"></p>';
  77. }
  78.  
  79. if($firstCurrency == "canadian" AND $secondCurrency == "british") {
  80. $convertedAmount = $amount * 0.58;
  81. return $convertedAmount;
  82. echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
  83. echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="englandFlag.jpg" width="65" height="45"</p>';
  84. }
  85.  
  86. if($firstCurrency == "canadian" AND $secondCurrency == "china") {
  87. $convertedAmount = $amount * 5.21;
  88. return $convertedAmount;
  89. echo '"<p><center><b>Your original amount was " . $amount . <img src="canadaFlag.jpg">,/p>';
  90. echo '"<p><center><b>Your new amount is " . $convertedAmount . <img src="chineseFlag.jpg" width="115" height="95"</p>';
  91. }
  92. }
  93.  
  94. if (isset($_POST['submit'])){
  95.  
  96. $amount = htmlspecialchars($_POST['amount']);
  97. $firstCurrency = htmlspecialchars($_POST['firstCurrency']);
  98. $secondCurrency = htmlspecialchars($_POST['secondCurrency']);
  99.  
  100. conversion($amount, $firstCurrency, $secondCurrency);
  101. }
  102.  
  103. ?>
  104.  
  105. </body>
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement