<html>
<head>
<title>Menggunakan Variabel</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table>
<tr>
<td>
Masukan Nilai Anda
</td>
<td>
: <input type="text" name="nilai" id="nilai">
</td>
</tr>
<td colspan="2">
<input type="submit" name="submit" value="Kirim Data" id="submit">
</td>
</tr>
</table>
</form>
<?php
@$nilai = $_POST['nilai'];
@$nilaiAngka = $_POST['nilai'];
@$submit = $_POST['submit'];
if(($submit<0)|| ($nilaiAngka>100))
{
echo "Nilai angka yang diberikan salah";
}
else
{
if (($nilai >= 80) && ($nilai <= 100))
{
$nilaihuruf = "A";
}
else if (($nilai >= 70) && ($nilai <= 79))
{
$nilaihuruf = "B";
}
else if (($nilai >= 60) && ($nilai <= 69))
{
$nilaihuruf = "C";
}
else if (($nilai >= 50) && ($nilai <= 59))
{
$nilaihuruf = "D";
}
else if (($nilai >= 0) && ($nilai <= 49))
{
$nilaihuruf = "E";
}
echo "----BIODATA NILAI SISWA-----<br>";
echo "Nilai Angka : $nilai <br>";
echo "Nilai Huruf : $nilaihuruf <br>";
echo "-----------------------<br>";
}
?>
</body>
</html>
<head>
<title>Menggunakan Variabel</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table>
<tr>
<td>
Masukan Nilai Anda
</td>
<td>
: <input type="text" name="nilai" id="nilai">
</td>
</tr>
<td colspan="2">
<input type="submit" name="submit" value="Kirim Data" id="submit">
</td>
</tr>
</table>
</form>
<?php
@$nilai = $_POST['nilai'];
@$nilaiAngka = $_POST['nilai'];
@$submit = $_POST['submit'];
if(($submit<0)|| ($nilaiAngka>100))
{
echo "Nilai angka yang diberikan salah";
}
else
{
if (($nilai >= 80) && ($nilai <= 100))
{
$nilaihuruf = "A";
}
else if (($nilai >= 70) && ($nilai <= 79))
{
$nilaihuruf = "B";
}
else if (($nilai >= 60) && ($nilai <= 69))
{
$nilaihuruf = "C";
}
else if (($nilai >= 50) && ($nilai <= 59))
{
$nilaihuruf = "D";
}
else if (($nilai >= 0) && ($nilai <= 49))
{
$nilaihuruf = "E";
}
echo "----BIODATA NILAI SISWA-----<br>";
echo "Nilai Angka : $nilai <br>";
echo "Nilai Huruf : $nilaihuruf <br>";
echo "-----------------------<br>";
}
?>
</body>
</html>