Advertisement
Guest User

root.php

a guest
Nov 24th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.08 KB | None | 0 0
  1. <?php
  2. class data{
  3.         function __construct(){
  4.                 $hostname = "localhost";
  5.                 $database = "db_terate";
  6.                 $username = "root";
  7.                 $password = "";
  8.             }
  9.         function login($username,$password){
  10.             $query=mysql_query("select * from pembeli where username='$username' and password='$password'");
  11.             $check=mysql_num_rows($query);
  12.             $data=mysql_fetch_array($query);
  13.             if($check>0){
  14.                 session_start();
  15.                 $_SESSION['pembeli']=$data['username'];
  16.                 $_SESSION['id_pembeli']=$data['id_pembeli'];
  17.                 header("location:index.php");
  18.                 }
  19.             else{
  20.                 ?>
  21.                 <script>
  22.                 alert("login gagal, mungkin username atau password anda salah");
  23.                 window.location.href="login.php";
  24.                 </script>
  25.                 <?php
  26.                 }
  27.             }
  28.         function daftar_pelanggan($username,$nama_lengkap,$email,$password,$alamat,$provinsi,$kabupaten,$kecamatan,$kode_pos,$no_telp){
  29.             $data=mysql_query("INSERT into pembeli SET username='$username',nama_lengkap='$nama_lengkap',email='$email',password='$password',alamat='$alamat',provinsi='$provinsi',kabupaten='$kabupaten',kecamatan='$kecamatan',kode_pos='$kode_pos',no_telp='$no_telp'") or die(mysql_error());
  30.                 ?>
  31.                     <script>
  32.                         alert("Selamat Bergabung & Selamat Datang Di TERATE STORE");
  33.                         window.location.href="index.php";
  34.                     </script>
  35.                 <?php
  36.             }
  37.         function tampil_produk_elektronik_list(){
  38.             $query=mysql_query("SELECT * from produk where kelompok='elektronik' order by id desc");
  39.                 while($r=mysql_fetch_array($query)){
  40.                     ?>
  41.                     <div class="col-md-3 product-grids">
  42.                         <div class="agile-products">
  43.                             <div class="new-tag"><h6><?php echo $r['diskon']; ?></h6></div>
  44.                             <a href="single.html"><img src="admin/<?php echo $r['gambar'] ?>" class="img-responsive" alt="img" style="width: 200px; height: 150px;"></a>
  45.                             <div class="agile-product-text">              
  46.                                 <h5><a href="single.html"><?php echo $r['nama_produk']; ?></a></h5>
  47.                                 <h6>Rp.<?php echo number_format($r['harga'],0,',','.'); ?></h6>
  48.                                 <form action="#" method="post">
  49.                                     <input type="hidden" name="cmd" value="_cart"/>
  50.                                     <input type="hidden" name="add" value="1"/>
  51.                                     <input type="hidden" name="w3ls_item" value="Queen Size Bed"/>
  52.                                     <input type="hidden" name="amount" value="250.00"/>
  53.                                     <button type="submit" class="w3ls-cart pw3ls-cart"><i class="fa fa-cart-plus" aria-hidden="true"></i> Add to cart</button>
  54.                                 </form>
  55.                             </div>
  56.                         </div>
  57.                     </div>
  58.                     <?php
  59.                 }
  60.         }
  61.             function tampil_produk_rekomendasi(){
  62.             $query=mysql_query("SELECT * from produk where kelompok='pakaian' order by id desc");
  63.                 while($r=mysql_fetch_array($query)){
  64.                     ?>
  65.                     <div class="item">
  66.                         <div class="glry-w3agile-grids agileits">
  67.                             <div class="new-tag"><h6><?php echo $r['diskon']; ?></h6></div>
  68.                             <a href="products1.html"><img src="admin/<?php echo $r['gambar'] ?>" alt="img"></a>
  69.                             <div class="view-caption agileits-w3layouts">          
  70.                                 <h4><a href="products1.html"><?php echo $r['nama_produk']; ?></a></h4>
  71.    
  72.                                 <h5><?php echo $r['harga']; ?></h5>
  73.                                 <a href="detail.php?id_barang=<?php echo $r['id'] ?>"><button type="submit" class="w3ls-cart" ><i class="fa fa-cart-plus"></i> Beli</button></a>
  74.                             </div>        
  75.                         </div>
  76.                     </div>
  77.                     <?php
  78.                 }
  79.         }
  80.         function tampil_produk_elektronik(){
  81.                 $query=mysql_query("SELECT * from produk where kategori='Elektronik' order by id desc LIMIT 10");
  82.                 while($r=mysql_fetch_array($query)){
  83.                     ?>
  84.                         <div class="item">
  85.                                         <div class="glry-w3agile-grids agileits">
  86.                                             <a href="elektronik.php"><img src="admin/<?php echo $r['gambar'] ?>" alt="img" style="width: 200px; height: 200px;"></a>
  87.                                             <div class="view-caption agileits-w3layouts">          
  88.                                                 <h4><a href="elektronik.php" style="color: #fff"><?php echo $r['nama_produk']; ?></a></h4>
  89.                    
  90.                                                 <h5 style="float: left;">Rp.<?php echo number_format($r['harga'],0,',','.'); ?></h5>
  91.                                                 <a href="detail.php?id_barang=<?php echo $r['id'] ?>"><button type="submit" class="w3ls-cart" ><i class="fa fa-cart-plus"></i> Beli</button></a>
  92.                                             </div>        
  93.                                         </div>  
  94.                         </div>
  95.                     <?php
  96.                 }
  97.             }
  98.             function tampil_produk_olahraga(){
  99.                 $query=mysql_query("SELECT * from produk where kelompok='olahraga' order by id desc LIMIT 10");
  100.                 while($r=mysql_fetch_array($query)){
  101.                     ?>
  102.                         <div class="item">
  103.                                         <div class="glry-w3agile-grids agileits">
  104.                                             <a href="detail.php?id_barang=<?php echo $r['id'] ?>"><img src="admin/<?php echo $r['gambar'] ?>" alt="img" style="width: 200px; height: 200px;"></a>
  105.                                             <div class="view-caption agileits-w3layouts">          
  106.                                                 <h4><a href="products.html" style="color: #fff"><?php echo $r['nama_produk']; ?></a></h4>
  107.                    
  108.                                                 <h5 style="float: left;">Rp.<?php echo number_format($r['harga'],0,',','.'); ?></h5>
  109.                                                 <a href="detail.php?id_barang=<?php echo $r['id'] ?>"><button type="submit" class="w3ls-cart" ><i class="fa fa-cart-plus"></i> Beli</button></a>
  110.                                             </div>        
  111.                                         </div>  
  112.                         </div>
  113.                     <?php
  114.                 }
  115.             }
  116.         function tampil_produk_pakaian(){
  117.                 $query=mysql_query("SELECT * from produk where kelompok='pakaian' order by id desc LIMIT 5");
  118.                 while($r=mysql_fetch_array($query)){
  119.                     ?>
  120.                         <div class="item">
  121.                                         <div class="glry-w3agile-grids agileits">
  122.                                             <a href="detail.php?id_barang=<?php echo $r['id'] ?>"><img src="admin/<?php echo $r['gambar'] ?>" alt="img" style="width: 200px; height: 200px;"></a>
  123.                                             <div class="view-caption agileits-w3layouts">          
  124.                                                 <h4><a href="fashion.php" style="color: #fff"><?php echo $r['nama_produk']; ?></a></h4>
  125.                    
  126.                                                 <h5 style="float: left;">Rp.<?php echo number_format($r['harga'],0,',','.'); ?></h5>
  127.                                                
  128.                                                 <a href="detail.php?id_barang=<?php echo $r['id'] ?>"><button type="submit" class="w3ls-cart" ><i class="fa fa-cart-plus"></i> Beli</button></a>
  129.            
  130.                                             </div>        
  131.                                         </div>  
  132.                         </div>
  133.                     <?php
  134.                 }
  135.             }
  136.  
  137.         function tampil_produk_fashion(){
  138.             $query=mysql_query("SELECT * from produk where kelompok='pakaian' order by id desc");
  139.                 while($r=mysql_fetch_array($query)){
  140.                     ?>
  141.                     <div class="col-md-3 product-grids">
  142.                         <div class="agile-products">
  143.                             <div class="new-tag"><h6><?php echo $r['diskon']; ?></h6></div>
  144.                             <a href="single.html"><img src="admin/<?php echo $r['gambar'] ?>" class="img-responsive" alt="img" style="width: 200px; height: 150px;"></a>
  145.                             <div class="agile-product-text">              
  146.                                 <h5><a href="single.html"><?php echo $r['nama_produk']; ?></a></h5>
  147.                                 <h6>Rp.<?php echo number_format($r['harga'],0,',','.'); ?></h6>
  148.                
  149.                                     <a href="detail.php?id_barang=<?php echo $r['id'] ?>><button type="submit" class="w3ls-cart" ><i class="fa fa-cart-plus" aria-hidden="true"></i> Beli</button></a>
  150.                                
  151.                             </div>
  152.                         </div>
  153.                     </div>
  154.                     <?php
  155.                 }
  156.         }
  157.         function tampil_pro(){
  158.                 $query=mysql_query("select * from produk");
  159.                 while($r=mysql_fetch_array($query)){
  160.                     $hasil[]=$r;
  161.                     }return $hasil;
  162.             }
  163.         function get_one($id_barang){
  164.             $query=mysql_query("select * from produk where id='$id_barang'");
  165.             $aray=mysql_fetch_array($query);
  166.             return $aray;
  167.             }
  168.         function beli($id_pembeli,$id_barang,$nama_produk,$gambar,$qty,$harga,$kategori,$keterangan,$jasa_pengiriman){
  169.             $query=mysql_query("INSERT into produk_temp set id_pembeli='$id_pembeli',id_produk='$id_barang',nama_produk='$nama_produk',harga='$harga',total_harga='$harga',gambar='$gambar',qty_beli='1',qty_asli='$qty',kategori='$kategori',ket='$keterangan',jasa_pengiriman='$jasa_pengiriman'");
  170.             $qtyy=$qty-1;
  171.             mysql_query("update produk set qty='$qtyy' where id='$id_barang'");
  172.             header('location:checkout.php');
  173.             }
  174.         function produk_temp($id_pembeli){
  175.             $data=mysql_query("select * from produk_temp where id_pembeli='$id_pembeli'");
  176.             while($r=mysql_fetch_array($data)){
  177.                 $hasil[]=$r;
  178.                 }return $hasil;
  179.             }
  180.         function temp_jumlah($id_pembeli){
  181.             $data=mysql_query("select * from produk_temp where id_pembeli='$id_pembeli'");
  182.             $row=mysql_num_rows($data);
  183.             return $row;
  184.             }
  185.         function logout(){
  186.             session_start();
  187.             unset($_SESSION['pembeli']);
  188.             ?>
  189.                 <script>
  190.                     alert("Anda Berhasil Logout");
  191.                     window.location.href="index.php"
  192.                 </script>
  193.             <?php
  194.             }
  195.         function batalkan($id){
  196.             $data=mysql_query("select * from produk_temp where id='$id'");
  197.             $balik=mysql_fetch_array($data);
  198.             $qty=$balik['qty_asli']+$balik['qty_beli'];
  199.             mysql_query("update produk set qty='$qty' where id='".$balik['id_produk']."'");
  200.             mysql_query("delete from produk_temp where id='$id'");
  201.             header("location:checkout.php");
  202.            
  203.             }
  204.         function qtytambah($id,$id_produk,$qty,$harga){
  205.            
  206.             $qtyy=$qty+1;
  207.             $qty2=$qtyy-1;
  208.             $harga2=$harga*$qtyy;
  209.             $tambah=mysql_query("update produk_temp set qty_beli='$qtyy',qty_asli='$qty2',total_harga='$harga2' where id='$id'");
  210.             $produk=mysql_query("select * from produk where id='$id_produk'");
  211.             $ganti=mysql_fetch_array($produk);
  212.             $qtyproduk=$ganti['qty']-1;
  213.             mysql_query("update produk set qty='$qtyproduk' where id='$id_produk'");
  214.             header("location:checkout.php");
  215.             }
  216.         function qtykurang($id,$id_produk,$qty,$harga){
  217.            
  218.             $qtyy=$qty-1;
  219.             $qty2=$qtyy+1;
  220.             $harga2=$harga*$qtyy;
  221.             $tambah=mysql_query("update produk_temp set qty_beli='$qtyy',qty_asli='$qty2',total_harga='$harga2' where id='$id'");
  222.             $produk=mysql_query("select * from produk where id='$id_produk'");
  223.             $ganti=mysql_fetch_array($produk);
  224.             $qtyproduk=$ganti['qty']+1;
  225.             mysql_query("update produk set qty='$qtyproduk' where id='$id_produk'");
  226.             header("location:checkout.php");
  227.             }
  228.         function total_bayar($id_pembeli){
  229.             $query=mysql_query("select sum(total_harga) as total from produk_temp where id_pembeli='$id_pembeli'");
  230.             $fetch=mysql_fetch_array($query);
  231.             $total=$fetch[total];
  232.             return $total;
  233.             }
  234.         function pilih_orang($id_pembeli){
  235.             $query=mysql_query("select * from pembeli where id_pembeli='$id_pembeli'");
  236.             $aray=mysql_fetch_array($query);
  237.             return $aray['alamat'];
  238.                         }
  239.         function pilih_orang_kabupaten($id_pembeli){
  240.             $query=mysql_query("select * from pembeli where id_pembeli='$id_pembeli'");
  241.             $aray=mysql_fetch_array($query);
  242.             return $aray['kabupaten'];
  243.                         }
  244.         function pilih_orang_kecamatan($id_pembeli){
  245.             $query=mysql_query("select * from pembeli where id_pembeli='$id_pembeli'");
  246.             $aray=mysql_fetch_array($query);
  247.             return $aray['kecamatan'];
  248.                         }
  249.         function pilih_orang_provinsi($id_pembeli){
  250.             $query=mysql_query("select * from pembeli where id_pembeli='$id_pembeli'");
  251.             $aray=mysql_fetch_array($query);
  252.             return $aray['provinsi'];
  253.                         }
  254.         function pilih_orang_kode_pos($id_pembeli){
  255.             $query=mysql_query("select * from pembeli where id_pembeli='$id_pembeli'");
  256.             $aray=mysql_fetch_array($query);
  257.             return $aray['kode_pos'];
  258.                         }
  259.         function pilih_orang_no_telp($id_pembeli){
  260.             $query=mysql_query("select * from pembeli where id_pembeli='$id_pembeli'");
  261.             $aray=mysql_fetch_array($query);
  262.             return $aray['no_telp'];
  263.                         }
  264.         function pilih_orang_jasa_pengiriman($id_pembeli){
  265.             $query=mysql_query("select * from produk_temp where id_pembeli='$id_pembeli'");
  266.             $aray=mysql_fetch_array($query);
  267.             return $aray['jasa_pengiriman'];
  268.                         }
  269.         function selesaibelanja($id_pembeli,$nama,$jumlah_barang,$jumlah_bayar,$tanggal_beli,$alamat,$kabupaten,$kecamatan,$provinsi,$kode_pos,$no_telp,$jasa_pengiriman){
  270.             if($jumlah_bayar==0){
  271.             ?>
  272.                      <script>
  273.          alert("Keranjang anda masih kosong");
  274.          window.location.href="index.php";
  275.          </script>
  276.             <?php
  277.             }else{
  278.             $query=mysql_query("INSERT into selesai set id_pembeli='$id_pembeli',nama='$nama',jumlah_barang='$jumlah_barang',jumlah_bayar='$jumlah_bayar',tanggal_beli='$tanggal_beli',alamat='$alamat',kabupaten='$kabupaten',kecamatan='$kecamatan',provinsi='$provinsi',kode_pos='$kode_pos',no_telp='$no_telp',jasa_pengiriman='$jasa_pengiriman',konfir='N'");
  279.             mysql_query("delete from produk_temp where id_pembeli='$id_pembeli'");
  280.             $rand=rand();
  281.             header("location:finish.php?nama=$nama&jumlah_barang=$jumlah_barang&tanggal_beli=$tanggal_beli&alamat=$alamat&kabupaten=$kabupaten&kecamatan=$kecamatan&provinsi=$provinsi&kode_pos='$kode_pos'&no_telp='$no_telp'&jasa_pengiriman='$jasa_pengiriman'&bayar=$jumlah_bayar&kode=$rand");
  282.            
  283.             }
  284.             }
  285.         function konfirmasi($kode_pembelian,i$id_vendor,$nama_bank,$tgl,$pesan,$gambar){
  286.             $s=mysql_query("INSERT INTO konfirmasi set kode_pembelian='$kode_pembelian',id_vendor='$id_vendor',nama_bank='$nama_bank',tgl='$tgl',pesan='$pesan',gambar='$gambar' ");
  287.             ?>
  288.                 <script type="text/javascript">
  289.                     alert("Anda Telah Berhasil Melakukan Konfirmasi Pembayaran");
  290.                     window.location.href="index.php"
  291.                 </script>
  292.             <?php
  293.         }
  294.         function selesai($id){
  295.             $query=mysql_query("select * from selesai where id_pembeli='$id'");
  296.             while($r=mysql_fetch_array($query)){
  297.                 $hasil[]=$r;
  298.                 }return $hasil;
  299.             }
  300.    
  301.     }
  302.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement