Soal Latihan(soal lengkap)
1. Latihan form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<FORM ACTION="prosesform.php" METHOD="POST" NAME="input">
<h2>HANDPHONE SHOP</h2>
<p>Produk GSM Mobile (Best Price)</p>
<input type="checkbox" name="hp1" value="Nokia 1208 Rp. 350.000,-"
checked> Nokia 1208 Rp. 350.000,-<br>
<input type="checkbox" name="hp2" value="Nokia 1661 Rp. 465.000,-">
Nokia 1661 Rp. 465.000,-<br>
<input type="checkbox" name="hp3" value="SonyEricsson K330 Rp. 485.000,-">
SonyEricsson K330 Rp. 485.000,-<br>
<input type="checkbox" name="hp4" value="Samsung Champ Rp. 865.000,-">
Samsung Champ Rp. 865.000,-<br>
<input type="checkbox" name="hp5" value="Samsung B3410 Rp. 1.624.000,-">
Samsung B3410 Rp. 1.624.000,-<br>
=========================================
<p>Data Customer</p>
ID Customer : <input type="text" name="id_customer"><br>
Nama : <input type="text" name="nama"><br>
Email : <input type="text" name="email"><br>
Alamat : <input type="text" name="alamat"><br>
Member :
<input type="radio" name="member" value="member" checked>
Member<br>
<input type="radio" name="member" value="bukan">
Bukan<br>
Pembayaran :
<select name="pembayaran">
<option value="VISA">VISA</option>
<option value="MASTERCARD">MASTERCARD</option>
<option value="DEBIT BCA">DEBIT BCA</option>
</select>
<p> <input type="submit" name="Proses" value="Proses"> </p>
</FORM>
</body>
</html>
2. Hasil
ketika kita membuka progaram diatas maka hasilnya adalah di bawah ini.
3. Proses form
dalam memasukan/mengisi data,seperti mencentang hp,mengisi id custumer,nama dan lain,akan dibutuhkan program seperti di bawah ini.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proses Handphone Shop</title>
</head>
<body>
<?php
// $hp1 = $_POST['hp1'];
// $hp2 = $_POST['hp2'];
// $hp3 = $_POST['hp3'];
// $hp4 = $_POST['hp4'];
// $hp5 = $_POST['hp5'];
$id_customer = $_POST['id_customer'];
$nama = $_POST['nama'];
$email = $_POST['email'];
$alamat = $_POST['alamat'];
$member = $_POST['member'];
$pembayaran = $_POST['pembayaran'];
echo "Produk yang dibeli :<br>";
if (isset($_POST['hp1'])) {
echo $_POST['hp1'] . "<br>";
$hp1 = 350000;
} else {
$hp1 =0;
}
if (isset($_POST['hp2'])) {
echo $_POST['hp2'] . "<br>";
$hp2 = 465000;
} else {
$hp2 =0;
}
if (isset($_POST['hp3'])) {
echo $_POST['hp3'] . "<br>";
$hp3 = 485000;
} else {
$hp3 =0;
}
if (isset($_POST['hp4'])) {
echo $_POST['hp4'] . "<br>";
$hp4 = 865000;
} else {
$hp4 =0;
}
if (isset($_POST['hp5'])) {
echo $_POST['hp5'] . "<br>";
$hp5 = 1624000;
} else {
$hp5 =0;
}
echo "======================================================";
echo "<p>Data Customer</p>";
echo "ID Customer : $id_customer <br>";
echo "Nama : $nama <br>";
echo "Email : $email <br>";
echo "Alamat : $alamat <br>";
echo "Member : $member <br>";
echo "Pembayaran : $pembayaran <br>";
$total = $hp1 + $hp2 + $hp3 + $hp4 + $hp5;
echo "Pembayaran Akhir = $total <br>";
if ($member == "member"){
echo "Diskon member = 10% <br>";
$totalmember = $total - ($total * 0.1);
}
?>
</body>
</html>
4. Hasil
ketika kita sudah memasukan data atau mengisi data, maka hasil ouput adalah di bawah ini;
Tidak ada komentar:
Posting Komentar