Latihan Web PHP 1

 


BENS FLORIS

No Transaksi:
Kode Bunga    :
Jumlah Beli   :
Jenis Kirim           :Diantar
                                       Tidak Diantar




Input bunga.php
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>a
<body bgcolor=#808080>
</pre>
<form action="simpanbunga.php" method="post">
<font color=#D2D200>
<table bgcolor=#00000 border=4 cellpedding=3 cellspacing=3 align=�center�>
<tr>
<td>
<strong><div align="center">BENS FLORIS</div></strong>
<tr><td>
<strong>No Transaksi</strong>:<input type="text" name=notrans><br>
<strong>Kode Bunga</strong>    :<Select name=kdbunga>
<option>A</option>
<option>T</option>
<option>M</option></select><br>
<strong>Jumlah Beli</strong>   :<input type="text" name=jumbel><br>
<strong>Jenis Kirim</strong>           :<input type="radio" name=jk value=Diantar>Diantar<br>
                                       <input type="radio" name=jk value=Tidak Diantar>Tidak Diantar<br>
<div align="center"><input type="submit" name=Simpan value=Simpan><input type="reset" name=Hapus Value=Hapus><br></div>
</tr></td>
</pre>
</form>
</table>
</font>
</body>
</html>


Simpanbunga.php
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<?
$koneksi=mysql_connect("localhost","root","password")or die("koneksi gagal".mysql_error());
echo"Data Berhasil Dimasukkan Ke Dalam Database<br>";

switch($kdbunga)
{
    case"A":
    $nmbunga=ANGGREK;
    $satuan=POT;
    $harga=60000;
    break;

    case"T":
    $nmbunga=TULIP;
    $satuan=TANGKAI;
    $harga=15000;
    break;

    default:
    $nmbunga=MAWAR;
    $satuan=BUNGKUS;
    $harga=30000;
    break;
}

if($jk=='Diantar'){$biaya=10000;}
else if($jk=='Tidak Diantar'){$biaya=0;}

$tobay=($harga*$jumbel)+$biaya;

echo"<pre>";
echo"<br>";
echo"No Transaksi:$notrans<br>";
echo"Kode Bunga  :$kdbunga<br>";
echo"Nama Bunga  :$nmbunga<br>";
echo"Harga       :Rp.$harga<br>";
echo"Satuan      :$satuan<br>";
echo"Jumlah Beli :$jumbel<br>";
echo"Biaya       :Rp.$biaya<br>";
echo"<hr>";
echo"Total Biaya :Rp.$tobay<br>";
echo"<hr>";
echo"</pre>";
mysql_select_db("maya",$koneksi)or die("koneksi gagal");
mysql_query("insert into bunga values('$notrans','$kdbunga','$nmbunga',
'$harga','$satuan','$jumbel','$biaya','$tobay')",$koneksi);
echo"Simpan Data Berhasil<br>";

$sql="select *from bunga";
$qry=mysql_db_query("maya",$sql,$koneksi)or die("ada yang salah");

echo"<a href=bunga.php>Mau Isi lagi ?</a>";
?>
</body>
</html>
Best Regard,

0 comments:

Post a Comment

No Coment No Spam!!!

Image Hosted by ImageShack.us