Showing posts with label Latihan php. Show all posts
Showing posts with label Latihan php. Show all posts

Latihan UAS Web programing ll

koneksi.php

<?
$koneksi=mysql_connect("localhost","root","password") or die (mysql_error());
$db="akademik_12099939";
mysql_select_db($db,$koneksi)or die(mysql_error());
?>

tampil.php

html>
<head>
<title>Daftar anggota Klub Hebat</title>
</head>
<body>

<?
include "koneksi.php";

$sql="select nama,email,komentar from buku_tamu";
if(!$query=mysql_query($sql))echo mysql_error();
while($row=mysql_fetch_array($query)){

echo "nama     :$row[nama]<br>";
echo "email    :$row[email]<br>";
echo "komentar :$row[komentar]<br>";
echo"<hr>";


}
 ?>
 <br>
 <a href="buku_tamu.php">Isi komentar lagi?...</a>
 </body>
 </html>

edit.php 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
include"koneksi.php";
$sql="select*from mhs where nim='$E'";
$qry=mysql_query($sql,$koneksi)or die(mysql_error());
while($data=mysql_fetch_array($qry))
{
$nim=$data[0];
$nama=$data[1];
$jurusan=$data[2];
$kelas=$data[3];
?>
<form action="update.php" method="post">
  <font color="#0000FF" size="4"><strong>Data Yang Akan Diperbaiki nih ^_^ </strong></font><strong></strong>
  <table width="90%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td width="39%">Nama Lengkap</td>
      <td width="61%"> <input name="nama" type="text" id="nama2" value="<? echo $nama;?>"></td>
    </tr>
    <tr>
<td>Jurusan</td>
      <td>
        <select name="jurusan" id="jurusan" >
         
          <option value="MI">MI</option>
          <option value="KA">KA</option>
          <option value="TK">TK</option>
        </select></td>
    </tr>
    <tr>
<td>Kelas</td>
      <td>
        <input name="kelas" type="text" id="kelas" value="<? echo $kelas; ?>"></td>
    </tr>
    <tr>
<td colspan="2">
<div align="center">
          <input name="Update" type="submit" id="Update" value="Update">
          <input name="nim" type="hidden" id="nim" value="<? echo $nim; ?>">
        </div></td>
    </tr>
  </table>
</form>
<?
}
?>

</body>
</html>

update.php

<?php
include "koneksi.php";

$query=mysql_query("update mhs set nama='$nama', jurusan='$jurusan', kelas='$kelas' where nim='$nim'",$koneksi)
or die ("Gagal ".mysql_error());
if($query){
?>
<script language="javascript">
alert('Data Sudah Diperbaiki Yah!')
</scripp-equiv="refresh" content="0; url=tampil.php">
<?
}
?>

hapus.php

<?php
include "koneksi.php";

$query=mysql_query("delete from mhs where nim='$H'",$koneksi)
or die ("Gagal ".mysql_error());
if($query){
?>
<script language="javascript">
alert('Data Sudah Terhapus')
</script>
Share
»»  Baca lagi... Best Regard,

DATA FAKTUR

DATA FAKTUR

INPUT.PHP
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body bgcolor=yellow>
<form action=output2.php method="post">
<?
echo"<br>TGL  :" .date('l d-M-Y');
echo"<br> Jam :" .date('g:i:s A');
?>
<font face="Lucida Calligraphy" Size=4 color=#FFFFFF>
<p> Selamat DatanG </p>
<table border=4 bgcolor=balck cellspasing=5 cellpadding=25 align=center>
<pre>
<form action=output2.php method="post">
<tr><td colspan="6"><strong><div align="center">Data Faktur</strong></div></tr></td>

<tr>
<td>
No Faktur    :<td><input type="text" name="nofak"></tr></td>
<tr>
<td>
Tgl. Faktur  :<td><input type="text" name="tglfaktur"></tr></td>
<tr>
<td>
Nama Barang  :<td><Select size=1 name="nabar">
              <option value="kulkas">Kulkas</option>
              <option value="radio">Radio</option>
              <option value="lampu">Lampu</option></select></tr></td>
<tr>
<td>
Jumlah        <td><input type="text" name="qty"></tr></td>
<tr>
<td>
Jenis Bayar   <td><input type="radio" value="cash" name="jbayar">  Cash  <br>
                  <input type="radio" value="kredit" name="jbayar">  Kredit</tr></td>
<tr><td colspan="6">
<div align="center"><input type="submit" value="Masukan Data"> <input type="reset" value="Hapus Data">
</div>
</pre>
</td>
</tr>
</body>
</html>

OUTPUT.PHP
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body>
<?
$konek=mysql_connect("localhost","root","password")
or die ("koneksi gagal".mysql_error());
echo"Koneksi Berhasil<br>";

$sql="insert into faktur(nofak,tglfaktur,nabar,qty,jbayar)
values('$nofak','$tglfaktur','$nabar','$qty','$jbayar')";
$qry=mysql_db_query("12099939",$sql,$konek);

if($qry){
    print"berhasil disimpan<br>";
}
else{
    print"gak masuk<br>";
}
echo"<h3><center>Daftar Transaksi</center></h3>";

$sql="select*from faktur";
$qry=mysql_db_query("12099939",$sql,$konek)or die("gagal tampil".mysql_error());

echo"<pre>
<table border='4' align='center'>
<tr><td>No.faktur<td>tgl.Faktur<td>Nama Barang<td>Harga<td>Quality<td>Subtotal<td>Cara Bayar<td>Aksi";
while($row=mysql_fetch_row($qry))

{if($row[2]=="radio"){$harga=50000;}
if($row[2]=="lampu"){$harga=20000;}
if($row[2]=="kulkas"){$harga=800000;}
$subt=$harga*$row[3];
echo"<tr><td>$row[0]<td>$row[1]<td>$row[2]<td>$row[3]<td>$row[4]
<td><a href='hapus.php?nofak=$row[0]'>Hapus</a>";
echo"<br>";
}
echo"</table></pre>";
print"<a href='output1.php'>Masukan Data Lagi</a>";

 ?>
</body>
</html>
 HAPUS.PHP
 <!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body>
<?
$konek=mysql_connect("localhost","root","password")
or die ("koneksi hapus gagal".mysql_error());
$sql="DELETET FROM faktur WHERE nofak='$nofak'";
$qry=mysql_db_query("masukan nama database",$sql,$konek)
or die ("query salahh".mysql_error());
if($qry)(
echo"Data Berhasil Di Hapus";
echo"<a href=output.php>kembali ke tampil</a>
}
else
echo"GAGAL MENGHAPUS";
exit;?>
</body>
</html>

Data Faktur

No Faktur    :

Tgl. Faktur  :

Nama Barang  :

Jumlah       

Jenis Bayar  
  Cash 

                    Kredit


Share
»»  Baca lagi... Best Regard,

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>
Share
»»  Baca lagi... Best Regard,
Image Hosted by ImageShack.us