artikel uas pembrograman
Nama : Cicha Handika
Kelas : SI3H
NIM : 161410149
1.
CODING HOME
<html>
<head>
<meta
charset="UTF-8">
<title>
HOME </title>
<style>
body
{
background : red;
}
#content
{
height: 900px;
width
: 200px;
margin: auto;
margin-top: 10px;
margin-bottom:
50px;
padding: 10px;
border : 2px solid green;
background: white;
}
#isi1
{
text-align: center;
font-size
:20px;
width: 400px;
height : 50px;
margin-top : 10px;
matgin-bot : 10px;
padding: 10px;
border: 2px solid green;
background: white;
}
#isi2
{
text-align : center;
font-size
:20px;
width: 400px;
height : 50px;
margin : auto;
margin-top : 10px;
matgin-bot : 10px;
padding: 10px;
border: 2px solid green;
background: white;
}
#isi3
{
text-align: center;
font-size
:20px;
width: 400px;
height : 50px;
margin-top : 10px;
matgin-bot : 10px;
padding: 10px;
border: 2px solid green;
background: white;
float:center;
}
#isi3
{
text-align: center;
font-size
:20px;
width: 400px;
height : 50px;
margin-top : 10px;
matgin-bot : 10px;
padding: 10px;
border: 2px solid green;
background: white;
float:center;
}
#isi3
{
text-align: center;
font-size
:20px;
width: 400px;
height : 50px;
margin-top : 10px;
matgin-bot : 10px;
padding: 10px;
border: 2px solid green;
background: white;
float:center;
}
#bawah
{
text-align: center;
font-size
:20px;
width: 1300px;
height : 70px;
margin : auto;
margin-top : 10px;
matgin-bot : 10px;
padding: 10px;
border: 2px solid green;
background: white;
float:center;
}
</style>
</head>
<body>
<div
id="isi1"> <a href="home.php"
target="isi"> HOME </a> </div>
<div
id="isi3"><a href="profil.php"
target="isi"> PROFIL </a> </div>
<div
id="isi2"><a href="Biodata.php"
target="isi"> latihan </a> </div>
<div
id="isi2"><a href="Biodata.php"
target="isi"> latihan 1-20</a> </div>
<br><br><br><br><br><br><br><br><center><h1>
<font color="blue"> Selamat
Datang Diwebsite Saya </font></h1></center>
<div
id="bawah"> @ by CICHA HANDIKA<br> </div>
</body>
</html>
Hasil codding home
2.
Coding profil
<html>
<head>
<title> PROFIL </title>
</head>
<body>
<?php
echo "<body bgcolor='blue’>";
function biodata ($nama, $kelas,
$nim, $fakultas,$jurusan){
echo
"<center><h1>Nama :
$nama<br>
kelas : $kelas<br>
NIM :
$nim<br>
Fakultas : $fakultas<br>
Jurusan
:$jurusan<br>
";
}
biodata ("<right>Cicha
Handika","SI 3H","161410149","Ilmu
komputer","Sistem Infomasi</right>");
?>
<br><br>
<center> <a
href="home.php" target="isi"> Back to Menu </a>
</center>
</body>
<html>
Codding latihan 1
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 1
</center>
<form
method="POST">
Nama
: <input type="text" name="nama"
required><BR><BR>
Alamat
: <input type="text" name="alamat" required><BR><BR>
TTL : <input type="text"
name="TTL" required><BR><BR>
Program
studi : <input type="radio" name="Programstudi"
value="ILKOM" required checked> ILKOM<br><br>
<input
type="radio" name="Programstudi" value="Olahraga"
required checked> Olahraga<BR><BR>
<input
type="radio" name="Programstudi" value="Ekonomi"
required checked> Ekonomi<br><br>
Semester
:<input type="radio" name="semester"
value="13"> 1-3<br><br>
<input type="radio"
name="semester" value="46"> 4-6<br><br>
<input type="radio"
name="semester" value="10"> 7-10<br><br>
<input
type="submit" value="Simpan">
</form>
<?php
$nama
= $_POST["nama"];
$alamat
= $_POST["alamat"];
$TTL
= $_POST["TTL"];
$Programstudi
= $_POST["Programstudi"];
$semester
= $_POST["semester"];
echo
"Nama : $nama<br>";
echo
"Alamat: $alamat<br>";
echo
"TTL : $TTL<br>";
echo
"Programstudi : $Programstudi<br>";
if
($semester=='13') {
echo
"Semester : 1-3<br>";
echo
"biaya = 5000<br>";
}
elseif
($semester=='46') {
echo
"Semester : 4-6<br>";
echo
"biaya : 7500<br>";
}
elseif
($semester=='10') {
echo
"Semester : 7-10<br>";
echo
"biaya : 10000";
}
else{
echo
"Masukan data dahulu";
}
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 2
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 3
</center>
<form
method="POST">
<?php
$fileku="test.txt";
$filehandle=fopen($fileku, 'r');
while(! feof($filehandle))
{
$datastring = fgetc ($filehandle);
echo $datastring;
}
fclose($filehandle);
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 3
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 3
</center>
<form method="POST">
<?php
$nama="Cicha Handika";
$barang="sabun";
$jumlah=6;
$member="iya";
echo "<br>Namaanda =
$nama";
echo "<br>Namabarang yang
andainginbeli = $barang";
echo "<br>Jumlahbarang
yang inginandabeli = $jumlah";
switch ($barang) {
case ($barang=="sabun") :
echo
"<br>hargaSabuninisebesar = Rp.5.000";
break;
default:
echo
"<br>baranggaadaluniatbelikagak ??";
}
if ($member=="iya"
&& $jumlah>=3){
$barang=$sampo=5000;
$total=$sampo*$jumlah;
$diskon=$sampo*$jumlah*0.1;
$finals=$total-$diskon;
echo "<br>harga total yang
andabeliadalah = $total";
echo
"<br>andamendapatdiskonsebesar = $diskon";
echo "<br>jadi total =
$finals";
echo
"<br><br>Selamatandamendapatminyak fortune 1 liter";
}
else if ($member=="iya"
&& $jumlah<=3){
$barang=$sampo=5000;
$total=$sampo*$jumlah;
echo "<br>harga total yang
andabeliadalah = $total";
}
else if ($member=="tidak"
&& $jumlah>=5){
$barang=$sampo=5000;
$total=$sabun*$jumlah;
$diskon=$sabun*$jumlah*0.05;
$finals=$total-$diskon;
echo "<br>harga total yang
andabeliadalah = $total";
echo
"<br>andamendapatdiskonsebesar = $diskon";
echo "<br>jadi total =
$finals";
echo
"<br><br>Selamatandamendapatminyak fortune 1 liter";
}
else if ($member=="tidak"
&& $jumlah<=3){
$barang=$sabun=5000;
$total=$sabun*$jumlah;
echo "<br>harga total yang
andabeliadalah = $total";
}
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 4
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 4
</center>
<form method="POST">
<head><title>Web
Penjumlahan</title></head>
<body>
<h1>PERKALIAN</h1>
<form method="post">
<table>
<tr>
<td
align="center">Angka 1</td>
<td>*</td>
<td
align="center">Angka 2</td>
</tr>
<tr>
<td><input
type="number" name="angka1"/></td>
<td>*</td>
<td><input
type="number" name="angka2"/></td>
<td>=</td>
<?php
$hasil = "";
if(isset($_POST['KALIKAN'])){
$hasil = $_POST['angka1'] *
$_POST['angka2'];
}
?>
<td><input
type="text" name="hasil" disabled value="<?php echo
$hasil;?>"></td>
<td><input
type="submit" name="PERKALIAN"
value="Hitung"></td>
</tr>
</table>
</form>
</body>
</html>
?>
</body>
</html>
Hasil codding latihan 4
Codding latihan 5
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 5
</center>
<form method="POST">
<?php
// Nama File = Contohgetdate.php
$today = getdate();
print_r ($today);
?>
</body>
</html>
Codding latihan 6
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 6
</center>
<form method="POST">
<?php
// Nama file : vararraay.php
$nilai=array(1,2,5,10);
print_r($nilai);
?>
</body>
</html>
Codding latihan 7
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 7
</center>
<form method="POST">
<?php
// Nama file : basingg.php
$data="perkalian,6,pembagian";
$hasil=explode(",",$data);
print_r($hasil);
$hasil=implode(",",$hasil);
printf("<br>%s",$hasil);
?>
</body>
</html>
Codding latihan 8
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 8 </center>
<form method="POST">
<head><title>Web
Penjumlahan</title></head>
<body>
<h1>PEMBAGIAN</h1>
<form method="post">
<table>
<tr>
<td
align="center">Angka 1</td>
<td>/</td>
<td align="center">Angka
2</td>
</tr>
<tr>
<td><input
type="number" name="angka1"/></td>
<td>/</td>
<td><input
type="number" name="angka2"/></td>
<td>=</td>
<?php
$hasil = "";
if(isset($_POST['BAGIKAN'])){
$hasil = $_POST['angka1'] /
$_POST['angka2'];
}
?>
<td><input type="text"
name="hasil" disabled value="<?php echo
$hasil;?>"></td>
<td><input
type="submit" name="BAGIKAN"
value="Hitung"></td>
</tr>
</table>
</form>
</body>
</html>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 9
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 9
</center>
<form method="POST">
<head><title>Web
Penjumlahan</title></head>
<body>
<h1>PENGURANGAN</h1>
<form method="post">
<table>
<tr>
<td
align="center">Angka 1</td>
<td>-</td>
<td
align="center">Angka 2</td>
</tr>
<tr>
<td><input
type="number" name="angka1"/></td>
<td>-</td>
<td><input
type="number" name="angka2"/></td>
<td>=</td>
<?php
$hasil = "";
if(isset($_POST['KURANGI'])){
$hasil = $_POST['angka1'] -
$_POST['angka2'];
}
?>
<td><input
type="text" name="hasil" disabled value="<?php echo
$hasil;?>"></td>
<td><input
type="submit" name="PENGURANGAN"
value="Hitung"></td>
</tr>
</table>
</form>
</body>
</html>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 10
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 10
</center>
<form method="POST">
<?php
$today = date("F j, Y, g:i
a");
echo $today;
$today = date("m.d.y");
echo $today;
$today = date("j, n, y");
echo $today;
$today = date("Ymd");
echo $today;
$today = date('h-i-s, j-m-y, it is w
Day');
echo $today;
$today = date('\i\t \i\s \t\h\e jS
\d\\y.');
echo $today;
$today = date("D M j G:i:s T
Y");
echo $today;
$today = date('H:m:s \m \i\s\
\m\o\n\t\h');
echo $today;
$today = date("H:i:s");
echo $today;
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 11
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN
11 </center>
<form method="POST">
<?php
$string = 'abcdefghijk';
if(preg_match("/fgh/",
$string)) {
echo 'string beisi pola fgh';
} else {
echo 'Tida ada pola fgh dalam
string';
}
?>
center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 12
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 12
</center>
<form method="POST">
<?php
function fbiodata($nama,$tanggal_lahir,$tempat_lahir,$nim,$fakultas,$prodi){ echo"nama = $nama <br>
Tanggal Lahir =
$tanggal_lahir<br>
Tempat Lahir = $tempat_lahir <br>
NIM = $nim<br>
Fakultas = $fakultas<br>
Prodi = $prodi<br><br>";
}
fbiodata("sisi","29-01-1999","Jakarta","161410316","Ilmu
Komputer","Sistem Informasi");
fbiodata("niko","4-2-1998","Palembang","161410312","Ilmu
Komputer","Sistem Informasi");
fbiodata("ajeng","24-9-1998","BatuRaja","161410314","Ilmu
Komputer","Sistem Informasi");
fbiodata("riko","5-2-1998","Banten","161410234","Ilmu
Komputer","Sistem Informasi");
fbiodata("miko","19-5-1998","Bengkulu","161410233","Ilmu
Komputer","Sistem Informasi");
fbiodata("raka","5-4-1998","Bandung","161410322","Ilmu
Komputer","Sistem Informasi");
?>
center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 13
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN
15 </center>
<form method="POST">
<?php
function bilangan ($bilangan){
$faktor = array();
for ($i=1; $i <= $bilangan; $i++){
if ($bilangan % $i ==0){
$faktor[]=$i;
}
}
return $faktor;
}
$bilangan=10;
$faktorbilangan= bilangan
($bilangan);
echo"faktor dari $bilangan
adalah : ";
for ($n=0; $n < count
($faktorbilangan); $n++){
echo $faktorbilangan[$n]. " ";
}
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 14
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 14
</center>
<form method="POST">
<?php
$bil="120";
if ($bil % 3 ==0)
{
echo "Bilangan $bil
Merupakan Kelipatan 3";
}
else
{
echo "Bilangan $bil Bukan
Kelipatan 3";
}
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 15
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN
15 </center>
<form method="POST">
<?php
echo("Nama:cicha
handika<br> nim : 161410149<br> kelas : SI3H");
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 16
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 16
</center>
<form method="POST">
<html>
<head>
<meta
charset="UTF-8">
<title>Belajar
CSS</title>
<style>
h1.satu
{
text-shadow:
2px 2px 5px red;
}
h1.dua
{
text-shadow:
2px 2px 5px blue;
}
h1.tiga
{
text-shadow:
5px 5px 3px violet;
}
h1.empat
{
text-shadow:
2px 2px 15px black;
}
</style>
</head>
<boy>
<h1
class="satu">Belajar CSS di Duniailkom</h1>
<h1
class="dua">Belajar CSS di Duniailkom</h1>
<h1
class="tiga">Belajar CSS di Duniailkom</h1>
<h1
class="empat">Belajar CSS di Duniailkom</h1>
</body>
</html>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 17
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN
17 </center>
<form method="POST">
<html>
<head>
<meta
charset="UTF-8">
<title>Belajar
CSS</title>
<style>
div,p
{
widht:
300px;
height:
300px;
padding:
15px;
border:
15px solid red;
margin:
20px;
border-radius:
100%;
background-color:
yellow;
}
</style>
</head>
<body>
<div>Box
1</div>
<div>Box
2</p>
</body>
</html>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
Codding latihan 18
<?php
header("Content-type:image/png");
$gambar=imagecreate(600,600);
$hijau = imagecolorallocate($gambar,
335,155,0);
$hitam = imagecolorallocate($gambar,
335,335,335);
$x1=50; $x2=160;$x3=280;$x4=280;$x5=50;
$y1=200; $y2=100
;$y3=200;$y4=350;$y5=350;
imageline($gambar, $x1, $y1, $x2,
$y2, $hitam);
imageline($gambar, $x2, $y2, $x3,
$y3, $hitam);
imageline($gambar, $x3, $y3, $x4,
$y4, $hitam);
imageline($gambar, $x4, $y4, $x5,
$y5, $hitam);
imageline($gambar, $x5, $y5, $x1,
$y1, $hitam);
imagepng($gambar);
?>
</html>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
<?php
Codding latihan 19
<!DOCTYPE>
<html>
<head>
<meta >
<title>HASIL</title>
<style>
</style>
</head>
<body>
<?php
$nama_barang = $_POST['nama_barang'];
$harga = $_POST['harga'];
$jumlah = $_POST['jumlah'];
$status = $_POST['status'];
//menghitung subtotal
$subtotal = $harga ;
//Keterangan :
//jika statusnya member akan mendapat
diskon 50%.
//jika statusnya bukan member maka
tidak mendapat diskon. Jadi:
switch ($status){
case "member":
$diskonpelangan = $subtotal * 5/100;
break;
default:
$diskonpelangan = 0;
}
//Keterangan :
//jika jumlah pembelian lebih dari 3
maka mendapat diskon 50%.
//jika jumlah pembelian kurang dari 3 maka tidak
mendapat diskon. jadi:
switch ($jumlah){
case "3":
case "4";
case "5";
case "5";
case "6";
case "7";
case "8";
case "9";
case "10";
case "11";
case "12";
$diskonjumlah = $subtotal * 5/100;
break;
default:
$diskonjumlah = 0;
}
//menghitung ongkos kirim berdasarkan
kota tujuan
//menghitung total keseluruhan
$total = $subtotal - $diskonpelangan
- $diskonjumlah;
?>
<div align="center">
<table width="300"
border="1">
<tr>
<td colspan="2">
<div align="center">
<strong>HASIL PERHITUNGAN
PEMBELIAN BARANG</strong>
</div>
</td>
</tr>
<tr>
<td >Nama Barang</td>
<td ><?php echo
"$nama_barang"; ?></td>
</tr>
<tr>
<td >Harga</td>
<td ><?php echo "Rp.
".number_format($harga); ?></td>
</tr>
<tr>
<td >Jumlah</td>
<td><?php echo
"$jumlah"; ?></td>
</tr>
<tr>
<td>Subtotal</td>
<td><?php echo "Rp.
".number_format($subtotal); ?></td>
</tr>
<tr>
<td>Status</td>
<td><?php echo
"$status"; ?></td>
</tr>
<tr>
<td >Diskon pelangan</td>
<td ><?php echo "Rp.
".number_format($diskonpelangan); ?></td>
</tr>
<td>Diskon lebih dari
3</td>
<td><?php echo "Rp.
".number_format($diskonjumlah); ?></td>
</tr>
<tr>
<td>
<strong>Total</strong></td>
<td><?php echo "Rp.
".number_format($total); ?></td>
</tr>
</table>
<a
href="belajar.php"> << Kembali</a><br />
</div>
</body>
</html>
Codding process
<!DOCTYPE>
<html>
<head>
<meta >
<title>HASIL</title>
<style>
</style>
</head>
<body>
<?php
$nama_barang = $_POST['nama_barang'];
$harga = $_POST['harga'];
$jumlah = $_POST['jumlah'];
$status = $_POST['status'];
//menghitung subtotal
$subtotal = $harga ;
//Keterangan :
//jika statusnya member akan mendapat
diskon 50%.
//jika statusnya bukan member maka
tidak mendapat diskon. Jadi:
switch ($status){
case "member":
$diskonpelangan = $subtotal * 5/100;
break;
default:
$diskonpelangan = 0;
}
//Keterangan :
//jika jumlah pembelian lebih dari 3
maka mendapat diskon 50%.
//jika jumlah pembelian kurang dari 3 maka tidak
mendapat diskon. jadi:
switch ($jumlah){
case "3":
case "4";
case "5";
case "5";
case "6";
case "7";
case "8";
case "9";
case "10";
case "11";
case "12";
$diskonjumlah = $subtotal * 5/100;
break;
default:
$diskonjumlah = 0;
}
//menghitung ongkos kirim berdasarkan
kota tujuan
//menghitung total keseluruhan
$total = $subtotal - $diskonpelangan
- $diskonjumlah;
?>
<div align="center">
<table width="300"
border="1">
<tr>
<td colspan="2">
<div align="center">
<strong>HASIL PERHITUNGAN
PEMBELIAN BARANG</strong>
</div>
</td>
</tr>
<tr>
<td >Nama Barang</td>
<td ><?php echo
"$nama_barang"; ?></td>
</tr>
<tr>
<td >Harga</td>
<td ><?php echo "Rp.
".number_format($harga); ?></td>
</tr>
<tr>
<td >Jumlah</td>
<td><?php echo
"$jumlah"; ?></td>
</tr>
<tr>
<td>Subtotal</td>
<td><?php echo "Rp.
".number_format($subtotal); ?></td>
</tr>
<tr>
<td>Status</td>
<td><?php echo
"$status"; ?></td>
</tr>
<tr>
<td >Diskon pelangan</td>
<td ><?php echo "Rp.
".number_format($diskonpelangan); ?></td>
</tr>
<td>Diskon lebih dari
3</td>
<td><?php echo "Rp.
".number_format($diskonjumlah); ?></td>
</tr>
<tr>
<td>
<strong>Total</strong></td>
<td><?php echo "Rp.
".number_format($total); ?></td>
</tr>
</table>
<a
href="belajar.php"> << Kembali</a><br />
</div>
</body>
</html>
Codding latihan 20
<!DOCTYPE html>
<html>
<head>
<title>Nah</title>
</head>
<body>
<center><h1>LATIHAN 20
</center>
<form
method="POST">
<html>
<head>
<title>Kalkulator
Sederhana</title>
<style>
body
{
background-color:white;
}
.menu{
height:50px;
line-height:50px;
position:relative;
margin:auto;
}
.menu ul {
list-style:none;
}
.menu ul li a {
float:left;
width:150px;
display:block;
text-align:center;
color:white;
text-decoration:none;
text-transform:uppercase;
}
.menu ul li a:hover {
display:block;
}
.menu ul li:hover ul {
display:block;
}
.menu ul ul {
display:none;
list-style:none;
position:absolute;
left:170px;
top:50px;
width:150px;
}
.menu ul ul li a {
float:none;
display:block;
padding-left:2px;
text-align:center;
width:150px;
height:50px;
margin:-20px;
margin-top:15px;
}
.menu ul ul li a:hover {
color:white;
}
div{
font-size:20px;
}
.kalkulator{
width:
335px;
background:
red;
margin:
100px auto;
padding:
10px 20px 50px 20px;
}
.bil{
width:
300px;
margin:
5px;
border:
none;
font-size:
16pt;
padding:
10px;
}
.tombol{
background:
#EC5159;
padding:
10px 20px;
color:
black;
font-size:
15pt;
margin:10px;
}
.judul{
text-align:
center;
color:
#eee;
}
</style>
</head>
<body>
<?php
$bil1 = isset($_POST['bil1']) ?
$_POST['bil1'] : NULL;
$bil2 = isset($_POST['bil2']) ?
$_POST['bil2'] : NULL;
$hasil =
isset($hasil)?$_POST['hasil']:NULL;
if(isset($_POST['tambah'])){
$hasil = $bil1+$bil2;
}
if(isset($_POST['kurang'])){
$hasil = $bil1-$bil2; }
if(isset($_POST['kali'])){
$hasil = $bil1*$bil2;
}
if(isset($_POST['bagi'])){
$hasil = $bil1/$bil2;
}
if(isset($_POST['clear'])){
$hasil='';
$bil1='';
$bil2='';
}?>
<div class="menu">
<ul>
<li><a
href="Home.html">Home</a></li>
<li><a href="">Profil</a>
<ul>
<li><a
href="Biodata.html">latihan 2</a></li>
<li><a
href="Galeri.html">profil</a></li>
</ul>
</li>
<li><a
href="kalkulator.php">Latihan</a>
</li>
</ul>
</div>
<br></br>
<div
class="kalkulator">
<form action=""
method="post">
<h2 class="judul"> KALKULATOR </h2>
<input type="text"
name="bil1" value="" class="bil" >
<input type="text"
name="bil2" value="" class="bil" >
<input type="submit"
name="tambah" value="+" class="tombol">
<input type="submit"
name="kurang" value="-" class="tombol">
<input type="submit" name="kali"
value="X" class="tombol">
<input type="submit" name="bagi"
value=":" class="tombol">
<input type="text"
class="bil" value="<?php echo $hasil; ?>" >
<input type="submit"
name="clear" value="Clear" class="tombol">
</form>
</div>
</body>
</html>
}
else{
echo
"Masukan data dahulu";
}
?>
<center><h1> <a
href="home.php" target="isi"> Back to home
</h1></a> </center>
</body>
</html>
coding apa ni?
BalasHapushtml bang
Hapus