KALKULATOR
Coding :
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Kalkulator</title>
</head>
<body>
<form method="post" action="ini.php" id="test" name="form">
<table bgcolor=blue width=10>
<td width=5 height>
<input type="text" name="bil1"><br />
<input type="text" name="bil2"> <p align=center>=</p>
<input type="text" name="bil3" value="<?php if (isset($_GET['bil3'])) echo $_GET['bil3']?>" />
</td>
<tr>
<td >
<p align=center><input type="submit" name="tambah" value="+" />
<input type="submit" name="kurang" value="-" /><br /><br />
<input type="submit" name="kali" value="x" />
<input type="submit" name="bagi" value="/" /><br /><br />
<input type="submit" name="sisa" value="mod" />
<input type="submit" name="input" value="cancel" /></p>
</td>
</tr>
</table>
</form>
<?php
$bil1 = $_POST['bil1'];
$bil2 = $_POST['bil2'];
if ($tambah = $_POST['tambah'])
{
$hasil = $bil1 + $bil2 ;
}
if ($kurang = $_POST['kurang'])
{
$hasil = $bil1 - $bil2;
}
if ($kali = $_POST['kali'])
{
$hasil = $bil1 * $bil2 ;
}
if ($bagi = $_POST['bagi'])
{
$hasil = $bil1 / $bil2 ;
}
if ($mod = $_POST['sisa'])
{$hasil = $bil1 % $bil2 ;
}
header ("location:ini.php?bil3=$hasil");
?>
</body>
</html>
Komentar
Posting Komentar