Latihan lagi membuat formulir seperti gambar. dan logika if-nya dalam listing aja
listing file kursus.php
<body>
<form
name="form1" method="post"
action="output_kursus.php">
<table width="339"
border="0" align="center">
<tr>
<td colspan="2"><div
align="center">Formulir Pendaftaran Kursus <br>
- ImamSmart - </div></td>
</tr>
<tr>
<td width="151">No.
Formulir </td>
<td width="178"><input
name="no" type="text" id="no"></td>
</tr>
<tr>
<td>Nama</td>
<td><input name="nama"
type="text" id="nama"></td>
</tr>
<tr>
<td>Pelajaran yang diambil
</td>
<td><select
name="pelajaran" id="pelajaran">
<option value="MATEMATIKA"
selected>Matematika</option>
<option value="BHS.
INGGRIS">Bhs. Inggris</option>
<option value="BHS.
INDONESIA">Bhs. Indonesia</option>
</select></td>
</tr>
<tr>
<td>Jenjang</td>
<td><input
name="jenjang" type="radio" value="SD">
SD
<br>
<input name="jenjang"
type="radio" value="SMP">
SMP
<br>
<input name="jenjang"
type="radio" value="SMA">
SMA</td>
</tr>
<tr>
<td>Waktu</td>
<td><select
name="waktu" id="waktu">
<option value="pagi"
selected>Pagi</option>
<option
value="siang">Siang</option>
<option
value="malam">Malam</option>
</select></td>
</tr>
<tr>
<td colspan="2"><div
align="center">
<input type="submit"
name="Submit" value="Proses">
<input type="reset"
name="Reset" value="Batal">
</div></td>
</tr>
</table>
</form>
</body>
</html>
file proses output_kursus.php
<body>
<?php
if($_POST[pelajaran]=='MATEMATIKA')
{
if($_POST[jenjang]=='SD')
{
$biaya=150000;
}
elseif($_POST[jenjang]=='SMP')
{
$biaya=200000;
}
else
{
$biaya=300000;
}
}
elseif($_POST[pelajaran]=='BHS. INGGRIS')
{
if($_POST[jenjang]=='SD')
{
$biaya=100000;
}
elseif($_POST[jenjang]=='SMP')
{
$biaya=150000;
}
else
{
$biaya=200000;
}
}
else
{
if($_POST[jenjang]=='SD')
{
$biaya=150000;
}
elseif($_POST[jenjang]=='SMP')
{
$biaya=200000;
}
else
{
$biaya=250000;
}
}
echo"
<table width='339' border='0' align='center'>
<tr>
<td
colspan='2'><div align='center'>Formulir Pendaftaran Kursus <br>
- ImamSmart -
</div></td>
</tr>
<tr>
<td
width='151'>No. Formulir </td>
<td>: $no </td>
</tr>
<tr>
<td>Nama</td>
<td>:
$nama </td>
</tr>
<tr>
<td>Pelajaran yang diambil </td>
<td>:
$pelajaran </td>
</tr>
<tr>
<td>Jenjang</td>
<td>:
$jenjang </td>
</tr>
<tr>
<td>Waktu</td>
<td>:
$waktu </td>
</tr>
<tr>
<td>Biaya</td>
<td>:
$biaya </td>
</tr>
<tr>
<td
colspan='2'><div align='center'>Terima kasih Telah
Bergabung</div></td>
</tr>
<td>
<a
href=kursus.php>
input lagi
</a>
</td>
</table>";
?>
</body>
</html>