WELCOME TO RITJ TIPS TRICK & TUTORIALS

Sabtu, 20 Mei 2017

CARA MEMBUAT KALKULATOR SEDERHANA PHP

    SCRIPT :
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Tugas Operator Aritmatika</title>
</head>
<body>
<form method="POST" action="">
<?php

if (isset($_POST['tambah'])){
$bil1 = $_POST['bil1'];
$bil2 = $_POST['bil2'];

$hasil= $bil1 + $bil2;
}
if (isset($_POST['kali'])){
$bil1 = $_POST['bil1'];
$bil2 = $_POST['bil2'];

$hasil= $bil1 * $bil2;
}
if (isset($_POST['bagi'])){
$bil1 = $_POST['bil1'];
$bil2 = $_POST['bil2'];

$hasil= $bil1 / $bil2;
}
if (isset($_POST['kurang'])){
$bil1 = $_POST['bil1'];
$bil2 = $_POST['bil2'];

$hasil= $bil1 - $bil2;
}
if (isset($_POST['modulus'])){
$bil1 = $_POST['bil1'];
$bil2 = $_POST['bil2'];

$hasil= $bil1 % $bil2;
}
?>
<table  rules="none" border ="5" height="300" width="50" align="center" bgcolor="#CCFFCC">
<tr>
<td colspan="4" align="center"  bgcolor="#33FFF00"> <font color="black"><B>KALKULATOR SEDERHANA</b><br /><U>by:rumahitjambi.blogspot.co.id</font></td>
</tr>
<tr>
<td><input type="number" name="bil1" value="" style="width: 100px;height:35px;"//></td>
<td><input type="number" name="bil2" value=""  style="width: 100px;height:35px;"/></td>
<td>=</td>
<td><input type="text" name="hasil" value="<?php echo $hasil;?>"  style="width: 100px;height:35px;"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="tambah" value="+" button style="width: 150px;height:50px;"/></td>
<td colspan="2"><input type="submit" name="kali" value="X" button style="width: 115px;height:50px;" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="bagi" value="/" button style="width: 150px;height:50px;" /></td>
<td colspan="2"><input type="submit" name="kurang" value="-" button style="width: 115px;height:50px;" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="modulus" value="%" button style="width: 150px;height:50px;" /></td>
<td colspan="2"><input type="submit" name="reset" value="cancel" button style="width: 115px;height:50px;" /></td>
</tr>
</table>
</form>
</body>
</html>

Tidak ada komentar:

Posting Komentar