Ok... sekarang kita akan membuat sebuah kalkulator bebrbasis
web php. Yang mana sebelumnya kita sudah belajar membuat web sederhana,
<!DOCTYPE html>
<html>
<head>
<title>
Kalkulator Sederhana
</title>
</head>
<style
type="text/css">
.judul{font-family: comic sans ms; font-size: 32;
font-weight: bold}
td{font-family: verdana; font-size: 11}
a{font-family: comic sans ms; font-size: 16; font-weight:
bold; textdecoration:
none}
a:hover{color: #ff6600; font-size: 18}
h1{font-family: comic sans ms; font-size: 22; font-weight:
bold}
body{font-family: verdana; font-size: 12}
</style>
</head>
<body>
<body>
<table border="0" width="100%">
<tr bgcolor="#ff6600">
<td class="judul">WONG
JATIRAWA</td></tr>
</table>
<table border="0">
<tr bgcolor="#cccccc">
<td><a
href="http://localhost/web1.html">Home</a></td>
<td><a
href="http://localhost/profil.html">Profil</a></td>
<td><a
href="http://localhost/krs.html">KRS>>></a></td>
<td><a
href="http://localhost/kalkulator.html">Kalkulator>>></a></td>
<td width="90%"></td></tr>
</table>
<tr>
<td colspan="2"
align="right"><marquee
scrollamount="4"><b>MASIH TAHAB BELAJAR
</marquee></td>
<div
class="tabel">
<form
name="form1" action="hitung.php"
method="post">
<table
width="50%" border="2">
<tr>
<td colspan="2" >
<div
align="center">
<b>Kalkulator Sederhana</b>
</div>
</td>
</tr>
<tr>
<td
width="50%">
<div
align="center">
Nilai Pertama
</div>
</td>
<td
width="50%">
<div align="center">
<input
type="text" name="input1" value="">
</div>
</td>
</tr>
<tr>
<td>
<div
align="center">Operator</div>
</td>
<td>
<div
align="center">
<select
name="hitung">
<option
value="*">
Perkalian
</option>
<option
value="/">
Pembagian
</option>
<option
value="+">
Penjumlahan
</option>
<option
value="-">
Pengurangan
</option>
</select>
</div>
</td>
</tr>
<tr>
<td>
<div
align="center">
Nilai Kedua
</div>
</td>
<td>
<div
align="center">
<input
type="text" name="input2">
</div>
</td>
</tr>
<tr>
<td
colspan="2">
<div
align="center">
<input
type="submit" name="Submit" value="hitung">
</div>
</td>
</tr>
</table>
</form>
</div>
</body>
<style
type="text/css">
.tabel
{
}
</style>
</html>
Setelah kita mengetik scrip dari pada program kalkulator
maka selanjutnya yaitu kita simpan scrip tersebut ke dalam system C di dalaam
folder htdoc..berikut contohnya
Setelah kita simpan,, maka kita coba jalankan dengan
memanggil di web broser,, kalo nulis dan menyimpan dengan benar maka hasilnya
seperti ini
Nah di atas adalah hanya badan dari pada sistem kalkulator
saja belum ada ouput hasil dari pada hitung kalkulator,, untuk melengkapi hasil
hitung kita menulis lagi di halaman baru notepad ++ seperti berikut:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<style type="text/css">
.judul{font-family: comic sans ms; font-size: 32;
font-weight: bold}
td{font-family: verdana; font-size: 11}
a{font-family: comic sans ms; font-size: 16; font-weight:
bold; textdecoration:
none}
a:hover{color: #ff6600; font-size: 18}
h1{font-family: comic sans ms; font-size: 22; font-weight:
bold}
body{font-family: verdana; font-size: 12}
</style>
</head>
<body>
<body>
<table border="0" width="100%">
<tr bgcolor="#ff6600">
<td class="judul">WONG
JATIRAWA</td></tr>
</table>
<table border="0">
<tr bgcolor="#cccccc">
<td><a
href="http://localhost/web1.html">Home</a></td>
<td><a
href="http://localhost/profil.html">Profil</a></td>
<td><a
href="http://localhost/krs.html">KRS>>></a></td>
<td><a
href="http://localhost/kalkulator.html">Kalkulator>>></a></td>
<td width="90%"></td></tr>
</table>
<tr>
<td colspan="2"
align="right"><marquee scrollamount="4">MASIH
TAHAB BELAJAR
</marquee></td>
<body>
<?php
$pertama =
$_POST['input1'] ;
$kedua =
$_POST['input2'] ;
$operator =
$_POST['hitung'] ;
if($operator=='*')
{
$hasil = $pertama *
$kedua ;
echo "hasil
dari $pertama * $kedua adalah : $hasil" ;
}
elseif($operator=='/')
{
$hasil = $pertama /
$kedua ;
echo "hasil
dari $pertama / $kedua adalah : $hasil" ;
}
elseif($operator=='+')
{
$hasil = $pertama +
$kedua ;
echo "hasil
dari $pertama + $kedua adalah : $hasil" ;
}
elseif($operator=='-')
{
$hasil = $pertama /
$kedua ;
echo "hasil
dari $pertama - $kedua adalah : $hasil" ;
}
?>
</body>
</html>
Kemudian biasa kita simpan ketikan kita
Nahhh,,,, setelah kita simpan maka selanjutnya kita akan
mencobanya hasil dari pada membuat kalkulator berbasis web php
Saya contohkan mengkalikan angka 3*6 maka sama dengan 14,,
benar atau tidak mari kita lihat hasil di web browser
Nah apabila kamu menulis scripnya benar maka hasilnya akan
seperti gambar di atas ,,,
Begitulah cara membuat kalkulator web php,, singkat kan,, semoga bermanfaat dan
selamat mencoba yah,,,,,?????






0 komentar:
Posting Komentar