Website Toko Buku Sahabatku



                   1.  Halaman Awal


                   2. MenuBuat Akun
                                          
                   3. Menu Login.
                                        
                   4. Daftar Buku
                    5. Detail Buku
                                         
                      6. Kategori 
                                          
                        7. Katalog
                                              

                             8. Keranjang Belanja
                                         
                           9. Konfirm Pembayaran
                                         
Untuk Codingnya Sendiri Sebagai Berikut




1.coding tampilan awal (index.hph)
<?php
include"db.php";
session_start();
if(isset($_SESSION['email_su']))
{
                header("location:");
}
else if(isset($_SESSION['email_cus']))
{
                header("location:page/customer/home.php");
}
@$pesan = $_GET['pesan'];
if($pesan=="berhasil daftar")
{
                echo"<script type='text/javascript'>alert('Anda berhasil mendaftar,silahkan login');</script>";
}
else if($pesan=="login")
{
                echo"<script type='text/javascript'>alert('Anda harus login dulu');</script>";
}
?>
<!DOCTYPE html>
<html>
<head>
                <title>SahabatBuku.com</title>
                <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
                <link rel="stylesheet" type="text/css" href="css/style.css">
                <link rel="stylesheet" type="text/css" href="js/jquery-ui/jquery-ui.css">
                <script type="text/javascript" src="js/jquery.js"></script>
                <script type="text/javascript" src="js/jquery.js"></script>
                <script type="text/javascript" src="js/bootstrap.js"></script>
                <script type="text/javascript" src="assets/js/jquery-ui/jquery-ui.js"></script>
</head>
<body>
<div id="head">
                <div class="hdkiri">
                <a href="index.php">Sahabat<b>Buku</b>.com</a>
                </div>
                <div class="hdkanan">
                <form action="index.php" method="get">
                                <input type="text" name="judul" placeholder="cari buku yang anda inginkan disini.." class="cari">
                                <input type="submit" name="cari" value="cari" class="tombolcari">
                </form>
                <?php
                @$cari = $_GET['cari'];
                if($cari)
                {
                                $judul = $_GET['judul'];
                                $qry_cari_buku = mysql_query("SELECT * from buku where judul like '%$judul%'");
                }
                ?>
                </div>
</div>
<div id="menu">
                <div class="menukiri">
                                <ul>
                                <li><a href="index.php"><span class="glyphicon glyphicon-home"></span> Beranda</a></li>
                                <li><a href="index.php?page=cara"><span class="glyphicon glyphicon-question-sign"></span> Cara Beli</a></li>
                                <li><a href="index.php?page=tentang"><span class="glyphicon glyphicon-info-sign"></span> Tentang Kami</a></li>
                                </ul>
                </div>
                <div class="menukanan">
                <ul>
                                <li><a data-toggle="modal" data-target="#daftar" ><span class="glyphicon glyphicon-pencil"></span> Buat Akun</a></li>
                                <li><a data-toggle="modal" data-target="#login"><span class="glyphicon glyphicon-log-in"></span> Masuk</a></li>
                                <li><a href="#"><span class="glyphicon glyphicon-plus"></span> keranjang(0)</a></li>
                </ul>
                </div>
</div>
<div id="content">
                <div id="contentkiri">
                                <div class="welcome">
                                                <?php
                                                @$page = $_GET['page'];
                                                if($page=="tentang")
                                                {
 
include("tentang.php");
                                                }
                                                else if($page=="cara")
                                                {
                                                                include("carabeli.php");
                                                }
                                                else{
                                                                include("welcome.php");
                                                }
                                                ?>
                                </div>
                                <div class="produk">
                                                <div class="hdproduk">
                                                                Silahkan pilih buku-buku di bawah ini
                                                </div>
                                                <?php
                                                @$id_kategori = $_GET['kategori'];
                                                @$id_katalog = $_GET['katalog'];
                                                $q_seleksi_buku = mysql_query("SELECT * from buku where id_kategori='$id_kategori'");
                                                $q_seleksi_buku1 = mysql_query("SELECT * from buku where id_katalog='$id_katalog'");
                                                $q_buku = mysql_query("SELECT * from buku");
                                                if($id_kategori==0)
                                                { while($buku = mysql_fetch_array($q_buku)){
                                                ?>
                                                <div class="col-md-3">
                                                <div class="tamp_produk" style="border: solid #fff 1px;">
                                                                <?php include("produk.php"); ?>
                                                </div>
                                                </div>
                                                <?php } }
                                                else if($id_kategori>=1 && $id_katalog>=1) { while($seleksi_buku1=mysql_fetch_array($q_seleksi_buku1)){?>
                                                <div class="col-md-3">
                                                <div class="tamp_produk">
                                                                <?php include("seleksi_produk1.php"); ?>
                                                </div>
                                                </div>
                                                <?php }}
                                                else if($id_kategori>=1) { while($seleksi_buku=mysql_fetch_array($q_seleksi_buku)){?>
                                                <div class="col-md-3">
                                                <div class="tamp_produk">
                                                                <?php include("seleksi_produk.php"); ?>
                                                </div>
                                                </div>
                                                <?php }} ?>

                                </div>



                </div>
                <div id="contentkanan">
                                <div class="navkanan">
                                                <?php include("kategori.php") ?>
                                </div>
                                <div class="navkanan">
                                <?php
                                $q_seleksi_katalog = mysql_query("SELECT * from katalog where id_kategori='$id_kategori'");
                                if($id_kategori==0){
                                 include("katalog.php");
                                }else{
                                                include("seleksi_katalog.php");
                                }
                                 ?>
                                </div>
                </div>
</div>
<!-- modal login -->
<div id="login" class="modal fade">
                <div class="modal-dialog">
                                <div class="modal-content">
                                                <div class="modal-header" style="text-align:center;background:#4682b5;;color:#fff;">
                                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                                <h4 class="modal-title">Silahkan Login</h4>
                                                </div>
                                                <div class="modal-body">
                                                                <form action="actlogin.php" method="post">
                                                                                <div class="form-group">
                                                                                                <label>Username</label>
                                                                                                <input name="email" type="email" class="form-control" placeholder="email">
                                                                                </div>
                                                                                <div class="form-group">
                                                                                                <label>Password</label>
                                                                                                <input name="password" type="password" class="form-control" placeholder="Password">
                                                                                </div>                                                  
                                                                                <input type="submit" class="btn btn-primary" value="Masuk">
                                                                                belum punya akun? <a data-toggle="modal" data-target="#daftar">Daftar</a>
                                                                </div>
                                                </form>
                                </div>
                </div>
</div>

<!--modal daftar-->
<div id="daftar" class="modal fade">
                <div class="modal-dialog">
                                <div class="modal-content">
                                                <div class="modal-header" style="text-align:center;background:#4682b5;;color:#fff;">
                                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                                <h4 class="modal-title">Silahkan mengisi form pendaftaran</h4>
                                                </div>
                                                <div class="modal-body">
                                                                <form action="actdaftar.php" method="post">
                                                                                <div class="form-group">
                                                                                                <label>Nama</label>
                                                                                                <input name="nama" type="text" class="form-control" placeholder="Nama Lengkap anda">
                                                                                </div>
                                                                                <div class="form-group">
                                                                                                <label>Alamat Email</label>
                                                                                                <input name="email" type="email" class="form-control" placeholder="email anda">
                                                                                </div>
                                                                                <div class="form-group">
                                                                                                <label>Password</label>
                                                                                                <input name="pass" type="password" class="form-control" placeholder="password">
                                                                                </div>
                                                                                <input type="submit" class="btn btn-primary" value="Simpan">
                                                                </div>
                                                </form>
                                </div>
                </div>
</div>


<div id="detail" class="modal fade">

</div>

<!-- modal login dulu -->
<div id="logindulu" class="modal fade">
                <div class="modal-dialog">
                                <div class="modal-content">
                                                <div class="modal-header" style="text-align:center;background:#4682b5;;color:#fff;">
                                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                                <h4 class="modal-title">Silahkan Login dulu untuk dapat membeli</h4>
                                                </div>
                                                <div class="modal-body">
                                                                <form action="actlogin.php" method="post">
                                                                                <div class="form-group">
                                                                                                <label>Username</label>
                                                                                                <input name="email" type="email" class="form-control" placeholder="email">
                                                                                </div>
                                                                                <div class="form-group">
                                                                                                <label>Password</label>
                                                                                                <input name="password" type="password" class="form-control" placeholder="Password">
                                                                                </div>                                                  
                                                                                <input type="submit" class="btn btn-primary" value="Masuk">
                                                                                belum punya akun? <a data-toggle="modal" data-target="#daftar">Daftar</a>
                                                                </div>
                                                </form>
                                </div>
                </div>
</div>

<div id="footer" style="margin-top:1450px;">
                <?php include("footer.php") ?>
               
</div>
</body>
</html>

2.  Daftar
<?php
include"db.php";
$nama = $_POST['nama'];
$email = $_POST['email'];
$password = $_POST['pass'];
                mysql_query("INSERT INTO `customer` (`id_cus`, `nama_cus`, `email_cus`, `password_cus`) VALUES (NULL, '$nama', '$email', '$password')");
                header("location:index.php?pesan=berhasil daftar");
?>

3. Login
<div class="jumbotron">
<center>
<div class="hdlogin">
Silahkan Login untuk memulai
</div>
<form action="actlogin.php" method="post">
                <div class="login">
                <div class="form-group">
                <input type="text" name="email" class="form-control" placeholder="email anda" style="margin:10px;">
                <input type="password" name="password" class="form-control" placeholder="password anda" style="margin:10px;">
                <input type="submit" name="login" value="masuk" class="form-control" style="margin:10px;background:#0000ff;color:#fff;">
                </div>
                </div>
</form>
<b>belum punya akun?<a href="index.php?act=daftar"> daftar</a></b>
</center>
</div>

4. Daftar Buku
<center>
<img src="img/gambar_buku/<?php echo $buku['gambar']; ?>"><br>
<a href="#"><?php echo $buku['judul']; ?></a><br> Rp.<?php echo number_format($buku['harga']); ?>,-<br>
<?php
$qrystok = mysql_query("SELECT * FROM stok where id_buku='$buku[id_buku]'");
while($stok = mysql_fetch_array($qrystok)){
 ?>
<br><div style="text-align:center;">stok tersedia <b><?php echo $stok['stok']; ?></b></div>
<?php if($stok['stok']>=1){ ?>
<a data-toggle="modal" data-target="#detail" class="btn btn-success open" id='<?php echo  $buku['id_buku']; ?>'>detail</a>
<?php }} ?>


<script type="text/javascript">
   $(document).ready(function () {
   $(".open").click(function(e) {
      var m = $(this).attr("id");
                                   $.ajax({
            url: "detail.php",
                                                   type: "GET",
                                                   data : {id: m,},
                                                   success: function (ajaxData){
                                                   $("#detail").html(ajaxData);
                                                   $("#detail").modal('show',{backdrop: 'true'});
                                   }
                                   });
        });
      });
</script>

5.Detail Buku
<?php
include"db.php";
$kd = $_GET['id'];
$q_detail = mysql_query("SELECT * from buku where id_buku='$kd'");
$detail= mysql_fetch_array($q_detail);
?>

      <link rel="stylesheet" type="text/css" href="js/jquery-ui/jquery-ui.css">
      <script type="text/javascript" src="js/jquery.js"></script>
      <script type="text/javascript" src="js/jquery.js"></script>
      <script type="text/javascript" src="js/bootstrap.js"></script>
      <script type="text/javascript" src="assets/js/jquery-ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<div class="modal-dialog">
                <div class="modal-content">
                                <div class="modal-header" style="text-align:center;background:#4682b5;color:#fff;">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                <div class="container-fluid">
                                                                <h3>Detail buku "<i style="font-size:20px;"><?php echo $detail['judul']; ?></i>"</h3>
                                                </div>
                                </div>
                                <div class="modal-body">
            <div class="row">
                <div class="detailbuku">
                <div class="col-md-4">
                                <img src="img/gambar_buku/<?php echo $detail['gambar'];  ?>">
                </div>
                <div class="col-md-6">
                <table>
                <tr>
                <td width="140px;"><p>Judul</td><td>: <?php echo $detail['judul']; ?></p></td>
                <tr>
                <td><p>Pengarang</td><td>: <?php echo $detail['pengarang']; ?></p></td>
                </tr>
                <tr>
                <td><p>Penerbit</td><td>: <?php echo $detail['penerbit']; ?></p></td>
                </tr>
                <tr>
                <td><p>Jumlah Halaman</td><td>: <?php echo $detail['hal'] ?></p></td>
                </tr>
                <tr>
                <td><p>Harga</td><td>: Rp.<?php echo number_format($detail['harga'])?>,-</p></td>
                </tr>
                </table>
                </div>
                </div>
            </div>
            <i style="font-size:20px;">Deskripsi :</i><p><?php echo $detail['deskripsi']; ?></p>
                                </div>
                                <div class="modal-footer">
            <p>Anda harus login terlebih dahulu jika ingin membeli buku kami</p>
                                <button type="reset" class="btn btn-danger"  data-dismiss="modal" aria-hidden="true">
                                                Kembali
                                </button>
                            </div>
                </div>
</div>

<!-- modal login dulu -->
<div id="loginsek" class="modal fade">
      <div class="modal-dialog">
            <div class="modal-content">
                  <div class="modal-header" style="text-align:center;background:#2e8b57;color:#fff;">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">Silahkan Login dulu untuk dapat membeli</h4>
                  </div>
                  <div class="modal-body">
                        <form action="actlogin.php" method="post">
                              <div class="form-group">
                                    <label>Username</label>
                                    <input name="email" type="email" class="form-control" placeholder="email">
                              </div>
                              <div class="form-group">
                                    <label>Password</label>
                                    <input name="password" type="password" class="form-control" placeholder="Password">
                              </div>                       
                              <input type="submit" class="btn btn-success" value="Masuk">
                              belum punya akun? <a data-toggle="modal" data-target="#daftar">Daftar</a>
                        </div>
                  </form>
            </div>
      </div>
</div>

6. Kategori
<div class="hdnav">
Katalog
</div>
<ul class="kategori">
<?php
include"pagination2.php";
$querykategori = mysql_query("SELECT * from kategori");
                                $rpp = 4; // jumlah record per halaman
        $reload = "index.php?page=&pagination=true";
        @$page = intval($_GET["page"]);
        if($page<=0) $page = 1; 
        $tcount = mysql_num_rows($querykategori);
        $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number
        $count = 0;
        $i = ($page-1)*$rpp;
        $no_urut = ($page-1)*$rpp;
while(($count<$rpp) && ($i<$tcount)) {
  mysql_data_seek($querykategori,$i);
  $kategori = mysql_fetch_array($querykategori);
?>
<li><a href="index.php?kategori=<?php echo $kategori['id_kategori'] ?>"><span class="glyphicon glyphicon-list"></span> <?php echo $kategori['kategori'] ?></a></li>
<?php
$i++;
$count++;
} ?>
</ul>
 <div><?php echo paginate_kategori($reload, $page, $tpages); ?></div>

7. Katalog
<div class="hdnav">
Katalog
</div>
<ul class="kategori">
<?php
include"pagination1.php";
$querykatalog = mysql_query("SELECT * from katalog");
                                $rpp = 4; // jumlah record per halaman
        $reload = "index.php?page=&pagination=true";
        @$page = intval($_GET["page"]);
        if($page<=0) $page = 1; 
        $tcount = mysql_num_rows($querykatalog);
        $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number
        $count = 0;
        $i = ($page-1)*$rpp;
        $no_urut = ($page-1)*$rpp;
while(($count<$rpp) && ($i<$tcount)) {
  mysql_data_seek($querykatalog,$i);
  $katalog = mysql_fetch_array($querykatalog);
?>
<li><a href="index.php?katalog=<?php echo $katalog['id_katalog'] ?>&kategori=<?php echo $katalog['id_kategori']; ?>"><span class="glyphicon glyphicon-list"></span> <?php echo $katalog['katalog'] ?></a></li>
<?php
$i++;
$count++;
} ?>
</ul>
 <div><?php echo paginate_katalog($reload, $page, $tpages); ?></div>


8. Keranjang Belanja
<?php
$query_kode_beli = mysql_query("SELECT * from selesai where id_cus='$_SESSION[id_cus]' && status_beli='order'");
$data_kode_beli = mysql_fetch_array($query_kode_beli);
$kode_beli = $data_kode_beli['kode_beli'];
@$aksi = $_GET['aksi'];
if($aksi=="hapus")
{
                $idker = $_GET['id'];
                $qryker =mysql_query("SELECT * from keranjang where id_keranjang='$idker'");
                $data_ker=mysql_fetch_array($qryker);
                $qty1 = $data_ker['qty'];
                $qrystok =mysql_query("SELECT * from stok where id_buku='$data_ker[id_buku]'");
                $data_stok = mysql_fetch_array($qrystok);
                $qty2 = $data_stok['stok'];
                $stokakhir = $qty1+$qty2;
                mysql_query("UPDATE stok set stok='$stokakhir' where id_buku='$data_ker[id_buku]'");
                mysql_query("DELETE from keranjang where id_keranjang='$idker'");
                mysql_query("DELETE from pembelian where id_keranjang='$idker'");
                header("location:home.php?hal=keranjang");
}
$qrykeranjang = mysql_query("SELECT * from keranjang where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli'");
$ttl_harga = $qrykeranjang['total_harga'];
$byr = mysql_fetch_array(mysql_query("SELECT SUM(total_harga) as total_bayar from keranjang where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli'"));
$qtot = mysql_fetch_array(mysql_query("SELECT SUM(qty) as qty_total from keranjang where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli'"));
$b = $byr['total_bayar'];
$c = $qtot['qty_total'];
mysql_query("UPDATE selesai set qty_total='$c',bayar='$b' where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli'");
?>
<div class="hdkeranjang">
Keranjang Belanja
</div>
<table class="table table-stiped">
<th>judul buku</th>
<th><center>harga</center></th>
<th><center>qty</center></th>
<th><center>total harga</center></th>
<th><center>Aksi</center></th>
<?php
 while($isi_keranjang = mysql_fetch_array($qrykeranjang)){ ?>
<tr>
                <td><?php $id_buku = $isi_keranjang['id_buku']; $qrybuku=mysql_query("SELECT * from buku where id_buku='$id_buku'"); $data_buku=mysql_fetch_array($qrybuku); $judul = $data_buku['judul']; echo $judul;?></td>
                <td><center>Rp.<?php echo number_format($isi_keranjang['harga']); ?>,-</center></td>
                <td><center><?php echo $isi_keranjang['qty'];  ?></center></td>
                <td><center>Rp.<?php echo number_format($isi_keranjang['total_harga']);  ?>,-</center></td>
                <td><center>
                <a href="home.php?hal=keranjang&aksi=hapus&id=<?php echo $isi_keranjang['id_keranjang']; ?>"><span class="glyphicon glyphicon-remove"></span></a></center></td>
</tr>
<?php } ?>
<tr>
                <td colspan="2" style="text-align:center;"><b>Total<b></td><td><center><?php echo $c; ?></center></td><td><center>Rp.<?php echo number_format($b); ?>,-</center></td>
                <td><center><a href="home.php" class="btn btn-warning"><span class="glyphicon glyphicon-shopping-cart"></span> Continue Shopping</a>
                <a href="home.php?hal=checkout" class="btn btn-primary"><span class="glyphicon glyphicon-paste"> checkout</span></a></center></td>
</tr>
</table>

9.Konfim Pembayaran
<?php
include"../../db.php";
session_start();

$query_kode_beli = mysql_query("SELECT * from selesai where id_cus='$_SESSION[id_cus]' && status_beli='order'");
$data_kode_beli = mysql_fetch_array($query_kode_beli);
$kode_beli = $data_kode_beli['kode_beli'];
$query_cek_keranjang = mysql_query("SELECT * from keranjang where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli'");
$cek_keranjang = mysql_num_rows($query_cek_keranjang);
$id_buku = $_POST['id_buku'];
$qty = $_POST['qty'];
$harga = $_POST['harga'];
$total_harga = $qty*$harga;

$query_stok = mysql_query("SELECT * from stok where id_buku='$id_buku'");
$data_stok = mysql_fetch_array($query_stok);
$stok = $data_stok['stok'];
$stok_ubah = $stok-$qty;
mysql_query("UPDATE stok set stok='$stok_ubah' where id_buku='$id_buku'");

$query_id_buku = mysql_query("SELECT * FROM keranjang where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli' && id_buku='$id_buku'");
$data_id_buku = mysql_fetch_array($query_id_buku);
$idbuku = $data_id_buku['id_buku'];
if($cek_keranjang>=1)
{
if($id_buku==$idbuku)
{
$query_keranjang = mysql_query("SELECT * from keranjang where id_cus='$_SESSION[id_cus]' && kode_beli='$kode_beli' && id_buku='$id_buku'");
$data_keranjang = mysql_fetch_array($query_keranjang);
$qty_asli = $data_keranjang['qty'];
$qty_ubah = $qty_asli+$qty;
$total_harga_ubah = $harga*$qty_ubah;
mysql_query("UPDATE keranjang set qty='$qty_ubah',total_harga='$total_harga_ubah' where id_buku='$id_buku'");
mysql_query("UPDATE pembelian set qty='$qty_ubah',total_harga='$total_harga_ubah' where id_buku='$id_buku'");
header("location:home.php?hal=keranjang");
}
else
{
mysql_query("INSERT into keranjang set kode_beli='$kode_beli',id_cus='$_SESSION[id_cus]',id_buku='$id_buku',qty='$qty',harga='$harga',total_harga='$total_harga'");
mysql_query("INSERT into pembelian set kode_beli='$kode_beli',id_cus='$_SESSION[id_cus]',id_buku='$id_buku',qty='$qty',harga='$harga',total_harga='$total_harga'");
header("location:home.php?hal=keranjang");
}
}
else if($cek_keranjang==0){
$kode = rand();
mysql_query("INSERT into selesai set kode_beli='$kode',id_cus='$_SESSION[id_cus]'");
mysql_query("INSERT into keranjang set kode_beli='$kode',id_cus='$_SESSION[id_cus]',id_buku='$id_buku',qty='$qty',harga='$harga',total_harga='$total_harga'");
mysql_query("INSERT into pembelian set kode_beli='$kode',id_cus='$_SESSION[id_cus]',id_buku='$id_buku',qty='$qty',harga='$harga',total_harga='$total_harga'");
header("location:home.php?hal=keranjang");
}
?>
 
Tugas WEB
Galih Setia Adi P :A2.1300192
Jaya Firmansyah: A2.1400064

0 Komentar untuk "Website Toko Buku Sahabatku"

Silakan tinggalkan komentar anda. DILARANG KERAS menyimpan link blog/web pada komentar dengan tujuan backlink, Spam.

 
Copyright © 2014 Tutorial Kampus - All Rights Reserved
Template By. Catatan Info