Tuesday, November 27, 2012

form php buat form logika if sederhana

Listing input dan outputnya:


 rumahmakan.php
<body>
<form name="form1" method="post" action="rumahmakan_output.php">
  <table width="292" border="0" align="center">
    <tr>
      <td colspan="3"><div align="center">RUMAH MAKAN IMAM<br>
        Soto - Baso - Mie Ayam </div></td>
    </tr>
    <tr>
      <td width="102">No. Nota </td>
      <td colspan="2"><input name="no" type="text" id="no"></td>
    </tr>
    <tr>
      <td>Nama Pelanggan</td>
      <td colspan="2"><input name="nama" type="text" id="nama"></td>
    </tr>
    <tr>
      <td>Alamat/Telepon</td>
      <td colspan="2"><input name="alamat" type="text" id="alamat"></td>
    </tr>
    <tr>
      <td>Pilihan Menu</td>
      <td width="88">Makanan : <br>
        <select name="makan" id="makan">
          <option value="baso">BASO</option>
          <option value="mieayam" selected>MIE AYAM</option>
          <option value="soto">SOTO</option>
            </select></td>
      <td width="88">Minuman : <br>
        <select name="minum" id="minum">
          <option value="tehmanis">TEH MANIS</option>
          <option value="susu" selected>SUSU</option>
          <option value="jus">JUS</option>
                                </select></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td colspan="2"><input type="submit" name="Submit" value="Proses">
      <input type="reset" name="Reset" value="Batal"></td>
    </tr>
  </table>
</form>
</body>
</html>


 rumahmakan_output.php
<body>
<?php
if($_POST[makan]=='baso')
{
$hargamakan=12000;
}
elseif($_POST[makan]=='mieayam')
{
$hargamakan=10000;
}
else
{
$hargamakan=15000;
}

if($_POST[minum]=='tehmanis')
{
$hargaminum=3000;
}
elseif($_POST[minum]=='susu')
{
$hargaminum=5000;
}
else
{
$hargaminum=7000;
}
$total=$hargamakan+$hargaminum;
echo"
<table width='292' border='0' align='center'>
  <tr>
    <td colspan='3'><div align='center'>RUMAH MAKAN IMAM<br>
        Soto - Baso - Mie Ayam </div></td>
  </tr>
  <tr>
    <td width='102'>No. Nota </td>
    <td>:  $no</td>
  </tr>
  <tr>
    <td>Nama Pelanggan</td>
     <td>:  $nama</td>
  </tr>
  <tr>
    <td>Alamat/Telepon</td>
     <td>:  $alamat</td>
  </tr>
  <tr>
    <td>Pilihan Menu</td>
    <td width='88'>-Makanan : <br>
    $makan<br>
            </td>
    <td width='88'>-Minuman : <br>
    $minum
            </td>
  </tr>
  <tr>
    <td>Harga makan </td>
     <td>:  $hargamakan</td>
  </tr>
  <tr>
    <td>Harga minum </td>
    <td>:  $hargaminum</td>
  </tr>
  <tr bgcolor='#999999'>
    <td>Total</td>
     <td>:  $total</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan='2'>Terima kasih </td>
  </tr>

    <tr>
    <td>
                <a href=rumahmakan.php> Input lagi </a>
                </td>
</table>";
?>
</body>
</html>
Comments
0 Comments

0 comments:

Post a Comment