Tuesday, April 25, 2017

Script PHP Website toko online

 

Sekarang ini ada begitu banyak model toko online contohnya lazada, elevania, tokopedia, bukalapak dan masih banyak yang lainnya yang kalau gua sebutin satu persatu bisa gak selesai nh artikel. hehehehehehe.. ☺

langsung aja dah disini gua akan membagikan secara gratis script PHP toko online. berikut langkah-langkahnya,, oh iya gua lupa sebelum lu ikutin langkah-langkahnya lu buka dulu dreamweaver atau notepad. yuuuk sekarang kita lanjut lagi..

1. index.php


<?php
session_start();
include_once "library/inc.connection.php";
include_once "library/inc.library.php";
?>
<html>
<head>
<title>TOKO BONEKA FITRIA - Toko Boneka Online Lengkap, Terbaru dan Termurah</title>
<meta name="robots" content="index, follow">

<meta name="description" content="TOKO BONEKA FITRIA adalah Toko Boneka Online Lengkap yang menjual aneka macam Boneka Lucu dengan harga murah meriah, koleksi selalu baru dan dijamin harganya murah. Tersedia boneka kucing, boneka gajah, boneka sapi, boneka barbie, boneka Angry Bird, boneka beruang, boneka Doraemon, boneka gajah, boneka Gorila, boneka Keropi, boneka Panda, boneka Mario Bros, boneka Teddy Bear dan lainnya">

<meta name="keywords" content="toko boneka online, toko boneka, boneka sapi, boneka barbie, boneka Angry Bird, boneka beruang, boneka Doraemon, boneka gajah, boneka Gorila, boneka Keropi, boneka Panda, boneka Mario Bros, boneka Teddy Bear dan lainnya">

<link href="style/styles_user.css" rel="stylesheet" type="text/css">
<link href="style/button.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="js.popupWindow.js"></script>
</head>
<body>
<table width="800" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td colspan="2" bgcolor="#F5F5F5">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2"><img src="images/header.png" width="800" height="178"></td>
  </tr>
  <tr>
    <td colspan="2" align="right"><a href="?open=Home" target="_self"><strong>HOME</strong></a> | <a href="?open=Profil" target="_self"><strong>PROFIL</strong></a> | <a href="?open=Barang" target="_self"><strong>BARANG</strong></a> | <a href="?open=Panduan" target="_self"><strong>PANDUAN</strong></a> | <a href="?open=Konfirmasi" target="_self"><strong>KONFIRMASI</strong></a> </td>
  </tr>
  <tr>
    <td colspan="2" align="right" bgcolor="#CCCCCC"><form name="form1" method="post" action="?open=Barang-Pencarian">
      <strong>Cari Barang :</strong> 
      <input name="txtKeyword" type="text" size="30" maxlength="100">
        <input type="submit" name="btnCari" value=" Cari ">
    </form>
    </td>
  </tr>
  <tr>
    <td width="182" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="3">
        <tr>
          <td bgcolor="#CCCCCC"><strong>KONTAK YM </strong></td>
        </tr>
        <tr>
          <td><a href="ymsgr:sendIM?bonekatya@yahoo.com"><img border=0 src="http://opi.yahoo.com/online?u=bonekatya@yahoo.com&amp;m=g&amp;t=2" /></a></td>
        </tr>
        <tr>
          <td bgcolor="#CCCCCC"><strong>TELEPON</strong></td>
        </tr>
        <tr>
          <td>0812345678910</td>
        </tr>
        <tr>
          <td><?php if(file_exists ("login.php")) { include "login.php"; }  else { echo "file login.php belum ada"; } ?> </td>
        </tr>
        <tr>
          <td bgcolor="#CCCCCC"><strong>KATEGORI</strong></td>
        </tr>
         <?php
    $mySql = "SELECT * FROM kategori ORDER BY nm_kategori";
    $myQry = mysql_query($mySql, $koneksidb) or die ("Query salah : ".mysql_error());
    while($myData = mysql_fetch_array($myQry)) {
        $Kode = $myData['kd_kategori'];
    ?>
        <tr>
          <td> <?php echo "<a href=?open=Barang-Kategori&Kode=$Kode>$myData[nm_kategori]</a>"; ?> </td>
        </tr>
  <?php } ?>
    </table></td>
    <td width="603" valign="top" bgcolor="#FFFFFF"><?php include "buka_file.php"; ?></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="center" bgcolor="#F5F5F5"><span class="FOOT">Copyright &copy; 2014 All rights reserved by bonekaFitria.com <br>
TOKO BONEKA FITRIA - Toko Boneka Online Lengkap</span></td>
  </tr>
</table>
</body>
</html>
 

2.  info_home.php

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Home</title>
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td align="center"><img src="images/home.png" width="600" height="200"></td>
  </tr>
</table>
<?php include "barang.php"; ?>
</body>
</html>

3. barang.php

<?php
include_once "library/inc.connection.php";
include_once "library/inc.library.php";

# Nomor Halaman (Paging)
$baris = 10;
$hal = isset($_GET['hal']) ? $_GET['hal'] : 1;
$pageSql = "SELECT * FROM barang";
$pageQry = mysql_query($pageSql, $koneksidb) or die ("error paging: ".mysql_error());
$jml  = mysql_num_rows($pageQry);
$maks  = ceil($jml/$baris);
$mulai = $baris * ($hal-1); 
?>
<html>
<head>
<link href="style/user.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td colspan="2" align="center" bgcolor="#CCCCCC" scope="col"><strong>KOLEKSI BARANG </strong></td>
  </tr>
<?php
// Menampilkan daftar barang
$barangSql = "SELECT barang.*,  kategori.nm_kategori FROM barang 
   LEFT JOIN kategori ON barang.kd_kategori=kategori.kd_kategori 
   ORDER BY barang.kd_barang ASC LIMIT $mulai, $baris";
$barangQry = mysql_query($barangSql, $koneksidb) or die ("Gagal Query".mysql_error()); 
$nomor = 0;
while ($barangData = mysql_fetch_array($barangQry)) {
 $nomor++;
 $KodeBarang = $barangData['kd_barang'];
 $KodeKategori = $barangData['kd_kategori'];
 
 // Membaca file gambar
 if ($barangData['file_gambar']=="") {
  $fileGambar = "noimage.jpg";
 }
 else {
  $fileGambar = $barangData['file_gambar'];
 }
  
 // Warna baris data
 if($nomor%2==1) { $warna=""; } else {$warna="#F5F5F5";}
?>
  <tr>
    <td width="19%" align="center">
   <a href="?open=Barang-Lihat&Kode=<?php echo $KodeBarang; ?>"><img src="img-barang/<?php echo $fileGambar; ?>" width="100" border="0"> </a> <br>
      <div class='harga'>Rp. <?php echo format_angka($barangData['harga_jual']); ?> </div><br>
      <a href="?open=Barang-Beli&Kode=<?php echo $KodeBarang; ?>" class="button orange small"> <strong>Beli</strong></a> </td>
    <td width="81%" valign="top">
   <a href="?open=Barang-Lihat&Kode=<?php echo $KodeBarang; ?>">
      <div class='judul'><?php echo $barangData['nm_barang']; ?> </div>
      </a>
      
   <p><?php echo substr($barangData['keterangan'], 0, 200); ?> ....</p>
      <p><strong>Stok :</strong> <?php echo $barangData['stok']; ?></p>
    <strong>Kategori :</strong> <a href="?open=Kategori-Barang&Kode=<?php echo $KodeKategori; ?>"> <?php echo $barangData['nm_kategori']; ?> </a></td>
  </tr>
<?php } ?>
  <tr>
    <td colspan="2" align="center" bgcolor="#F5F5F5">
 <b>Halaman:
    <?php
 for ($h = 1; $h <= $maks; $h++) {
   echo "[  <a href='?hal=$h'>$h</a> ]";
 }
 ?>
    </b></td>
  </tr>
</table>
</body>
</html>


4. barang_kategori.php

<?php
include_once "library/inc.connection.php";
include_once "library/inc.library.php";

# Membaca Kode filter Kategori
if(isset($_GET['Kode'])) {
 // Membaca Kode dari URL
 $Kode = $_GET['Kode'];
 
 if (trim($_GET['Kode']) == "") {
  $filterSQL = " ";
 }
 else {
  $filterSQL = "WHERE barang.kd_kategori='$Kode'";
 }
}

# Nomor Halaman (Paging)
$baris = 10;
$hal  = isset($_GET['hal']) ? $_GET['hal'] : 1;
$pageSql= "SELECT * FROM barang $filterSQL ORDER BY kd_barang DESC";
$pageQry= mysql_query($pageSql, $koneksidb) or die ("error paging: ".mysql_error());
$jml = mysql_num_rows($pageQry);
$maks = ceil($jml/$baris);
$mulai = $baris * ($hal-1);

# Membaca data kategori
$infoSql = "SELECT * FROM kategori WHERE kd_kategori='$Kode'";
$infoQry = mysql_query($infoSql, $koneksidb) or die ("Query salah".mysql_error());
$infoData= mysql_fetch_array($infoQry);
?>
<html>
<head>
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td colspan="2" align="center" bgcolor="#CCCCCC" scope="col"><strong><?php echo strtoupper($infoData['nm_kategori']); ?></strong></td>
  </tr>
<?php
// Menampilkan daftar barang
$barang2Sql = "SELECT barang.*,  kategori.nm_kategori FROM barang 
   LEFT JOIN kategori ON barang.kd_kategori=kategori.kd_kategori 
   $filterSQL 
   ORDER BY barang.kd_barang ASC LIMIT $mulai, $baris";
$barang2Qry = mysql_query($barang2Sql, $koneksidb) or die ("Gagal Query".mysql_error()); 
$nomor = 0;
while ($barang2Data = mysql_fetch_array($barang2Qry)) {
  $nomor++;
  $KodeBarang = $barang2Data['kd_barang'];
  $KodeKategori = $barang2Data['kd_kategori'];
  
  // Menampilkan gambar utama
  if ($barang2Data['file_gambar']=="") {
  $fileGambar = "noimage.jpg";
  }
  else {
  $fileGambar = $barang2Data['file_gambar'];
  }
  
// Warna baris data
if($nomor%2==1) { $warna=""; } else {$warna="#F5F5F5";}
?>
  <tr>
    <td width="24%" align="center">
  <a href="?open=Barang-Lihat&Kode=<?php echo $KodeBarang; ?>">
  <img src="img-barang/<?php echo $fileGambar; ?>" width="100" border="0"> </a> <br>
  <div class='harga'>Rp. <?php echo format_angka($barang2Data['harga_jual']); ?> </div> <br>
  <a href="?open=Barang-Beli&Kode=<?php echo $KodeBarang; ?>" class="button orange small"> <strong>Beli</strong></a> </td>
    <td width="76%" valign="top">
  <a href="?open=Barang-Lihat&Kode=<?php echo $KodeBarang; ?>">
   <div class='judul'> <?php echo $barang2Data['nm_barang']; ?> </div> </a>
  <p><?php echo substr($barang2Data['keterangan'], 0, 200); ?> ....</p>
  <p><strong>Stok :</strong> <?php echo $barang2Data['stok']; ?></p>
 <strong>Kategori :</strong> <a href="?open=Kategori-Barang&Kode=<?php echo $KodeKategori; ?>"> <?php echo $barang2Data['nm_kategori']; ?> </a> </td>
  </tr>
<?php } ?>
  <tr>
    <td colspan="2" align="center"><b>Pages:
      <?php
 for ($h = 1; $h <= $maks; $h++) {
   echo "[  <a href='?open=Kategori-Barang&Kode=$KodeKategori&hal=$h'>$h</a> ]";
 }
 ?>
    </b></td>
  </tr>
</table>
</body>
</html>

5. barang_lainnya.php

<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td scope="col"><img src="images/barang_lainnya.gif" border="0" /></td>
  </tr>
  <tr>
    <th scope="col">
 <?php
 // Membaca Kode barang pada URL
 $Kode = $_GET['Kode'];

 // menampilkan daftar barang
 $barang3Sql = "SELECT barang.*,  kategori.nm_kategori FROM barang 
    LEFT JOIN kategori ON barang.kd_kategori=kategori.kd_kategori 
    WHERE barang.kd_kategori='$KodeKategori' AND barang.kd_barang != '$Kode' 
    ORDER BY barang.kd_barang DESC LIMIT 5";
 $barang3Qry = mysql_query($barang3Sql, $koneksidb) or die ("Gagal Query".mysql_error()); 
 $nomor = 0;
 while ($barang3Data = mysql_fetch_array($barang3Qry)) {
   $nomor++;
   $KodeBarang = $barang3Data['kd_barang'];
   $KodeKategori = $barang3Data['kd_kategori'];

   // menampilkan gambar utama
   if ($barang3Data['file_gambar']=="") {
   $fileGambar = "noimage.jpg";
   }
   else {
   $fileGambar = $barang3Data['file_gambar'];
   }
   
 // Warna baris data
 if($nomor%2==1) { $warna=""; } else {$warna="#F5F5F5";}
 ?>
        <table width="100%" border="0" cellspacing="0" cellpadding="4">
          <tr  bgcolor="<?php echo $warna; ?>">
            <td width="19%" align="center"  valign="top"><a href="?open=Barang-Lihat&amp;Kode=<?php echo $KodeBarang; ?>"> <img src="img-barang/<?php echo $fileGambar; ?>" width="100" border="0" /> </a> <br />
                <div class='harga'>Rp. <?php echo format_angka($barang3Data['harga_jual']); ?> </div>
              <br />
              <a href="?open=Barang-Beli&amp;Kode=<?php echo $KodeBarang; ?>" class="button orange small"> <strong>Beli</strong></a> </td>
            <td width="81%" valign="top"><a href="?open=Barang-Lihat&Kode=<?php echo $KodeBarang; ?>">
              <div class='judul'> <?php echo $barang3Data['nm_barang']; ?> </div>
              </a>
                <p><?php echo substr($barang3Data['keterangan'], 0, 200); ?> ....</p>
              <p><strong>Stok :</strong> <?php echo $barang3Data['stok']; ?></p>
              <strong>Kategori :</strong> <a href="?open=Kategori-Barang&Kode=<?php echo $KodeKategori; ?>"> <?php echo $barang3Data['nm_kategori']; ?> </a> <br />            </td>
          </tr>
        </table>
      <?php } ?></th>
  </tr>
  
</table>


6. barang_lihat.php

<?php
// Membaca Kode dari URL
if(isset($_GET['Kode'])){
 $Kode = $_GET['Kode'];
 
 // Menampilkan data sesuai Kode dari URL
 $lihatSql = "SELECT barang.*, kategori.nm_kategori FROM barang 
    LEFT JOIN kategori ON barang.kd_kategori=kategori.kd_kategori
    WHERE barang.kd_barang='$Kode'";
 
 $lihatQry = mysql_query($lihatSql, $koneksidb) or die ("Data Gagal Ditampilkan ..!");
 $no=0;
 $lihatData = mysql_fetch_array($lihatQry);
   $no++;
   $KodeBarang= $lihatData['kd_barang'];
   $KodeKategori = $lihatData['kd_kategori'];
      
   // Membaca gambar utama
   if ($lihatData['file_gambar']=="") {
   $fileGambar = "noimage.jpg";
   }
   else {
   $fileGambar = $lihatData['file_gambar'];
   }
} 
else {
 // Jika variabel Kode tidak ada di URL
 echo "Kode barang tidak ada ";
 
 // Refresh
 echo "<meta http-equiv='refresh' content='2; url=index.php'>";
 exit;
}
?>
<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="21%" align="center" valign="top">
 <img src="img-barang/<?php echo $fileGambar; ?>" width="200" border="0" /><br />
    <div class='harga'>Rp. <?php echo format_angka($lihatData['harga_jual']); ?> </div> <br />
    <a href="?open=Barang-Beli&Kode=<?php echo $KodeBarang; ?>" class="button orange small"> <strong>Beli</strong></a> </td>
    <td width="79%" align="center" valign="top">
 <table width="99%" border="0" cellspacing="2" cellpadding="3">
        <tr> 
          <td colspan="3"><img src="images/detail_barang.gif" ></td>
        </tr>
        <tr> 
          <td width="24%"><b>Nama  </b></td>
          <td width="1%">:</td>
          <td width="75%"><b><?php echo $lihatData['nm_barang']; ?></b> </td>
        </tr>
        <tr> 
          <td><b>Harga (Rp.)</b></td>
          <td>:</td>
          <td><?php echo format_angka($lihatData['harga_jual']); ?></td>
        </tr>
        <tr> 
          <td><b>Stok</b></td>
          <td>:</td>
          <td><?php echo $lihatData['stok']; ?></td>
        </tr>
        <tr> 
          <td><b>Kategori </b></td>
          <td>:</td>
          <td><?php echo $lihatData['nm_kategori']; ?></td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td colspan="3" valign="top"><?php echo $lihatData['keterangan']; ?></td>
        </tr>
      </table></td>
  </tr>
</table>
<?php
// Menampilkan barang lainnya (sejenis dengan barang yang sedang dilihat/ diview)
include "barang_lainnya.php";
?>

Untuk full source code silahkan komen di bawah ini.....
Previous Post
Next Post

4 comments: