Penulisannya adalah :
IF($kondisi="nilai") { Pernyataan; }else{ Pernyataan; } |
<html>
<head>
<Title>Latihan PHP</title>
</head>
<body>
<center>
<h1>Perhitungan Nilai Siswa SMK XYZ </h1>
<form name="form1" action="nilai.php" method="POST">
<table width=600px border = 0>
<tr>
<td colspan=3 align="center" bgcolor="grey"><font color="white">Data Siswa</font></td>
</tr>
<tr>
<td>Nama Siswa</td>
<td>:</td>
<td><input type="text" name="txtnama" width=200></input></td>
</tr>
<tr>
<td>Kelas</td>
<td>:</td>
<td><input type="text" name="txtkelas" width=100></input></td>
</tr>
<tr>
<td colspan=3 align="center" bgcolor="grey"><font color="white">Mata Pelajaran</font></td>
</tr>
<tr>
<td>Bahasa Indonesia</td>
<td>:</td>
<td><input type="text" name="txtbindo" width=100></input></td>
</tr>
<tr>
<td>Bahasa Inggris</td>
<td>:</td>
<td><input type="text" name="txtbingg" width=100></input></td>
</tr>
<tr>
<td>Matematika</td>
<td>:</td>
<td><input type="text" name="txtmtk" width=100></input></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" name="submit" value="Proses"></input></td>
</tr>
</table>
</form>
</body>
</html>
hasil simpan dengan nama datasiswa.html
berikutnya kita buat dokumen kedua
<html>
<head><title>Hasil</title></head>
<body>
<?php
$nama = $_POST['txtnama'];
$kelas = $_POST['txtkelas'];
$bindo = $_POST['txtbindo'];
$bingg = $_POST['txtbingg'];
$mtk = $_POST['txtmtk'];
$total = $bindo + $bingg + $mtk;
$rata = number_format(($bindo + $bingg + $mtk)/3,2);
echo "<h3>Hasil Nilai Ujian Siswa</h3>";
echo "==============================================<br>";
echo "<pre>";
echo "Nama Siswa : " .$nama;
echo "<br>";
echo "Kelas : " .$kelas;
echo "<br>";
echo "==============================================<br>";
echo "Nilai Bahasa Indonesia : " .$bindo;
echo "<br>";
echo "Nilai Bahasa Inggris : " .$bingg;
echo "<br>";
echo "Nilai Matematika : " .$mtk;
echo "<br>";
echo "Total Nilai : " .$total ;
echo "<br>";
echo "Nilai Rata-rata : " .$rata;
echo "<br>";
echo "==============================================</br>";
if ($rata>70) {
$keterangan = "LULUS";
}
else {
$keterangan = "GAGAL";
}
echo "</pre>";
echo "<h3>Keterangan : " .$keterangan. "</h3>";
?>
</body>
</html>
simpan dengan nama nilai.php
Untuk Latihan berikutnya cobalah kamu buat tampilan seperti ini
Selamat mengerjakan . :)
{ 0 comments... read them below or add one }
Post a Comment