contoh script toko online

koneksi.php

 

<?php

$server=”localhost”;

$username =”root”;

$password =””;

$database =”dtbarang”;

mysql_connect($server,$username,$password) or die(“gagal”);

mysql_select_db($database) or die(“Database tidak ditemukan”);

?>

 

 

prosesinput.php

 

<?php

include(“koneksi.php”);

mysql_query (“INSERT INTO dtbarang(kd_barang, nm_barang, harga) VALUES(‘$_POST[kd_barang]’,’$_POST[nm_barang]’,’$_POST[harga]’)”);

echo(“<table>”);

echo(“<tr><td>Kode Barang</td> <td>: <b>$_POST[kd_barang]</b></td></tr>”);

echo(“<tr><td>Nama Barang</td> <td>: <b>$_POST[nm_barang]</b></td></tr>”);

echo(“<tr><td>Harga Barang</td> <td>: <b>$_POST[harga]</b></td></tr>”);

echo(“<tr><td><form method=post action=tampil.php>”);

echo(“<input type=submit name=submit value=’Lihat Data’></form></td>”);

echo(“<td><form method=post action=input.php>”);

echo(“<input type=submit name=submit value=’Daftar lagi’></form></td></tr></table>”);

?>

 

 

tampil.php

 

<?php

echo(“DATA SISWA<br><hr><br>”);

echo(“<table border=1>”);

echo(“<tr><td>Kode Barang</td><td>Nama Barang</td><td>Harga Barang</td></tr>”);

include(“koneksi.php”);

$perintah=”select * from dtbarang order by harga”;

$tampil_data=mysql_query($perintah);

while($data=mysql_fetch_row($tampil_data))

{

echo(“<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>

<a href=edit.php?id=$data[0]>Edit</a></td><td>

<a href=hapus.php?id=$data[0]>Hapus</a></td></tr>”);

}

echo(“</table>”);

echo(“<form method=post action=input.php>”);

echo(“<input type=submit name=submit value=’Daftar Lagi’></form>”);

?>

 

 

update.php

 

<?php

include (“koneksi.php”);

mysql_query(“UPDATE tbbarang SET dt_barang=’$_POST[kd_barang]’, nm_barang=’$_POST[nm_barang]’, harga=’$_POST[harga]’ where kd_barang=’$_POST[kd_barang]’ “);

?>

 

 

hapus.php

 

<?php

include(“koneksi.php”);

mysql_query(“DELETE FROM tbbarang where dt_barang=’$_GET[id]'”);

?>

 

input.php

 

<html>

 

INPUT DATA BARANG

<table>

<form method=post action = prosesinput1.php>

<tr><td>Kode Barang</td><td>: <input type = text name=kd_barang size=25><br></td></tr>

<tr><td>Nama Barang</td><td>: <input type = text name=nm_barang size=30><br></td></tr>

<tr><td>Harga Barang</td><td>: <input type = text name=harga size=30> </td></tr>

<tr><td><input type=submit name=submit value=Proses></td>

<td><input type=reset name=reset value=Batal></td></tr>

</form>

</table>

</html>

 

 

 

edit1.php

 

<?php

include(“koneksi.php”);

$edit=mysql_query(“select * dtbarang where kd_barang=’$_GET[id]'”);

echo”<h2>Edit Data</h2>

<form method=POST action=update.php><table>

<tr><td>Kode Barang</td><td>: <input type=text name=kd_barang value=’$data[kd_barang]’>

</td></tr>

<tr><td>Nama Barang</td><td>: <input type=text name=nm_barang value=’$data[nm_barang]’>

</td></tr>

<tr><td>Harga Barang</td><td>: <input type=text name=harga value=’$data[harga]’>

</td></tr>

<tr><td colspan=2><input type=submit value=update>

<input type=button value=Batal onclick=self.history.back()></td></tr>

</table></form>”;

?>

 

 

transaksi.php

 

<?

 

 

 

?>

<?php

 

//buat variabel untuk menampung data dari file .html

$kaos_volcom = $_POST[‘kaos_volcom’]; //data kaos

$kaos_oneill = $_POST[‘kaos_oneill’];//data kaos

$jaket_cosmic = $_POST[‘jaket_cosmic’]; //data jaket

$jaket_ouval = $_POST[‘jaket_ouval’]; //data jaket

$sepatu_converse = $_POST[‘sepatu_converse’]; //data sepatu

 

//harga dari masingmasing produk

define(‘HARGA_KAOS1’,175000);

define(‘HARGA_KAOS2’,125000);

define(‘HARGA_JAKET1’, 225000);

define(‘HARGA_JAKET2’, 265000);

define(‘HARGA_SEPATU’, 275000);

 

//total harga

$total = (HARGA_KAOS1 * $kaos_volcom) + (HARGA_KAOS2 * $kaos_oneill) +

(HARGA_JAKET1 * $jaket_cosmic) + (HARGA_JAKET2 * $jaket_cosmic) + (HARGA_SEPATU * $sepatu_converse);

 

$diskon = 0;

$pesan_diskon = ‘0%’;

 

//cek total untuk menentukan diskon

if ($total >= 600000 && $total < 750000) {

$diskon = 0.05; //diskon 5%

$pesan_diskon = ‘5%’;

} elseif ($total >=750000 && $total < 1000000) {

$diskon = 0.1;// diskon 10%

$pesan_diskon = ‘10%’;

} elseif ($total >= 1000000) {

$diskon = 0.15; //diskon 15%

$pesan_diskon = ‘15%’;

}

$subtotal = $total – ($total * $diskon);

 

?>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

http://www.w3.org/TR/html4/loose.dtd”&gt;

<head>

<title>Pembelian Online</title>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-8″>

<style type=”text/css”>

.tanda {background-color:#cfcfcf;}

.style12 {

font-size: 24;

color: #FF0000;

}

.style13 {font-size: 24px; color: #000000; }

.style15 {color: #FF0000}

.style16 {

font-size: 24px;

color: #FF0000;

}

body {

background-image: url(background/back.jpg);

}

</style>

</head>

 

<body tracingsrc=”background/back.jpg” tracingopacity=”100″>

<table width=”815″ ></table>

<tr>

<td height=”119″><img src=”Wallpaper_1_1.jpg”width=”900″ height=”200″</td>

</tr>

<tr>

<td height=”573″><div align=”center”>

<p>&nbsp;</p>

<p align=”center”><span> DATA PEMBELIAN </span></p>

<div align=”right”>

<table width=”574″ height=”378″ border=”1″ align=”center”>

<tr>

<td width=”195″><div align=”center” class=”style15″>

<div align=”justify”>Barang</div>

</div></td>

<td width=”196″><div align=”center” class=”style15″>

<div align=”justify”>Jumlah</div>

</div></td>

<td width=”195″><div align=”center” class=”style15″>

<div align=”justify”>Total</div>

</div></td>

</tr>

<tr>

<td><span>Hand guns 1</span></td>

<td><span><?php echo $kaos_volcom;?></span></td>

<td><span><?php echo ($kaos_volcom * HARGA_KAOS1);?></span>

</tr>

<tr>

<td><span>Hand guns 2 </span></td>

<td><span><?php echo $kaos_oneill;?></span></td>

<td><span><?php echo ($kaos_oneill * HARGA_KAOS2);?></span>

</tr>

<tr>

<td><span>Hand guns 3 </span></td>

<td><span><?php echo$jaket_cosmic;?></span></td>

<td><span><?php echo($jaket_cosmic*HARGA_JAKET1);?></span>

</tr>

<tr>

<td><span>Hand guns 4 </span></td>

<td><span><?php echo $jaket_ouval;?></span></td>

<td><span><?php echo ($jaket_ouval * HARGA_JAKET2);?></span>

</tr>

<tr>

<td><span>Hand guns 5 </span></td>

<td><span><?php echo $sepatu_converse;?></span></td>

<td><span><?php echo ($sepatu_converse * HARGA_SEPATU);?></span>

</tr>

<tr class=”tanda”>

<td colspan=”2″><span class=”style15″>TOTAL</span></td>

<td><span class=”style15″><?php echo $total;?></span></td>

</tr>

<tr class=”tanda”>

<td colspan=”2″><span class=”style15″>Diskon</span></td>

<td><span><?php echo $pesan_diskon;?></span></td>

</tr>

<tr class=”tanda”>

<td colspan=”2″><span class=”style15″>SUBTOTAL</span></td>

<td><span><?php echo $subtotal;?></span></td>

</tr>

</table>

</div>

<p>&nbsp;</p>

</div></td>

</tr>

<tr>

<td height=”56″> <img src=”2.jpg” width=”130″ height=”100″> <img src=”colt-tactical-pistol.gif” width=”130″ height=”100″>  <img src=”WilsonHandguns_logo2.jpg” width=”130″ height=”100″>  <img src=”handgun1.jpg” width=”130″ height=”100″>  <img src=”air_sport_gun_m39-2.jpg” width=”130″ height=”100″> <img src=”Wallpaper_1_1.jpg” width=”130″ height=”100″></td>

</tr>

</table>

<p align=”center”>&nbsp;</p>

</body>

</html>

<?

 

?>

5 thoughts on “contoh script toko online

  1. What a gem😀 I found this place on Yahoo poking around for something completely different-
    now I’m gonna need to read through all the archives🙂 So much for my free time today, but this was a great find😀

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s