changer - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of changer.php

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  <title>Studi Kasus</title>
  5.  <style>
  6.   body{
  7.    text-align: center;
  8.    background-color: ghostwhite;
  9.   }
  10.   h1{
  11.    text-align: center;
  12.   }
  13.   th{
  14.    background-color: aqua;
  15.    border: 1px dashed black;
  16.   }
  17.   table{
  18.    border: 1px dashed black; 
  19.   }
  20.   td{
  21.    border-right: 1px solid black;
  22.    background-color: ghostwhite;
  23.   }
  24.   p{
  25.    font-family: cursive;
  26.   }
  27.   button{
  28.    transition: .3s;
  29.    background-color: aqua;
  30.    font-family: cursive;
  31.    border: 1px solid black
  32.   }
  33.   button:hover{
  34.    transition: .3s;
  35.    border-radius: 5px;
  36.    font-weight: bold;
  37.   }
  38.   select{
  39.    border-radius: 5px;
  40.    font-weight: bold;
  41.    background-color: aqua;
  42.    transition: .3s;
  43.   }
  44.   input{
  45.    border-radius: 5px;
  46.    border: 1px solid black;
  47.    padding: 3px;
  48.   }
  49.  </style>
  50. </head>
  51. <body>
  52.  <h1>
  53. Money Changer</h1>
  54. <table border="0" align="center" cellspacing="1" cellpadding="5">
  55. <tr>
  56.    <th>Mata uang asing</th>
  57.    <th>Mata uang indonesia</th>
  58.   </tr>
  59. <tr>
  60.    <td>Dollar amerika</td>
  61.    <td>12000</td>
  62.   </tr>
  63. <tr>
  64.    <td>Dollar singapura</td>
  65.    <td>7000</td>
  66.   </tr>
  67. <tr>
  68.    <td>Yen</td>
  69.    <td>4000</td>
  70.   </tr>
  71. <tr>
  72.    <td>Won</td>
  73.    <td>11</td>
  74.   </tr>
  75. </table>
  76. <h1>
  77. Transaksi</h1>
  78. <form action="" method="post">
  79.   Masukkan nominal anda : <input placeholder="Input Your Nominal" type="text" name="uang">
  80.   <select name="mataUang">
  81.    <option value="12000">Dollar Amerika</option>
  82.    <option value="7000">Dollar Singapura</option>
  83.    <option value="4000">Yen</option>
  84.    <option value="11">Won</option>
  85.   </select>
  86.   <button type="submit">Konversi</button>
  87.  </form>
  88. <?php 
  89.   $uang = (int)$_POST['uang'];
  90.   $mataUang = (int)$_POST['mataUang'];
  91.   $tipe = $mataUang == 12000 ? "Dollar Amerika" : ($mataUang == 7000 ? "Dollar Singapura" : ($mataUang == 4000 ? "Yen" : "Won"));
  92.   echo "<p>
  93. " . kembali($uang,$mataUang) . " " . $tipe . "</p>
  94. ";
  95.  
  96.   function kembali($uang,$mataUang){
  97.    return $uang / $mataUang ;
  98.   }
  99.   ?>
  100. </body>
  101. </html>
File Description
  • changer
  • PHP Code
  • 29 Oct-2019
  • 2 Kb
You can Share it: