Thursday, September 25, 2014

Form Pembelian

Latihan Pembelian
menggunakan bahasa pemrograman
PHP

by : Muhamad Ade Kurniawan



















<html>
<head>
<title>M.Ade => Form Pembelian</title>
</head>

<body>

<h1>Pembelian</h1> <br>

<form action="" method="post" name="input">
<table>
<tr>
<td>Nama Barang : </td> <td> <input type="text" size="20" name="nmBRG"> </td>
</tr>

<tr>
<td>Harga Satuan : </td> <td> <input type="text" size="20" name="hrBRG"> </td>
</tr>

<tr>
<td>Jumlah Barang : </td> <td>
<select name="jumlah">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
 </td>
</tr>

<tr>
<td>Uang : </td> <td> <input type="text" size="20" name="uang"> </td>
</tr>

<tr>
<td> <input type="submit" size="" name="total" value="total"> </td>
</tr>

</table>
</form>

<button onmouseover="getElementById('demo').innerHTML=Date()">The time is?</button>
<p id="demo"></p>

<?php
if (isset($_POST['total'])){
$nbrg = $_POST['nmBRG'];
$hbrg = $_POST['hrBRG'];
$jbeli = $_POST['jumlah'];
$total = $_POST['toHRG'];
$duit = $_POST['uang'];


$total = $hbrg * $jbeli;
$kembali = $duit - $total;

echo "Nama Barang = $nbrg</br>";
echo "Jumlah belanja = $total</br>";
echo "Uang bayar = $duit</br>";
echo "Kembalian = $kembali";

}
?>

</body>

</html>

2 comments: