Sie sind auf Seite 1von 4

<html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="head"> <a class="white" href="home.

html">PROFILE</a> &nbsp &nbsp <a class="white" href="register.html">REGISTER</a> &nbsp &nbsp <a class="white" href="contact us.html">CONTACT US</a></white> </div> <br/> <br/> <br/> <div class="body"> <table> <tr> <td class = "right"> Username :</td> <td> <input value="" type="text" name=nama size=25> </td> </tr> <tr> <td class = "right"> Password :</td> <td> <input value="" type="password" name=nama size=15> </td> </tr> <tr> <td class = "right"> Gender : </td> <td> <input type=radio name=gender value="Male" checked> Male <input type=radio name=gender value="Female" > Female </td> </tr> <tr> <td class = "right"> Most Favorite Taylor Swift Album : </td> <td> <select> <option selected>Taylor Swift</option> <option>Fearless</option> <option>Speak Now</option> </select> </td> </tr> <tr> <td class = "right"> Top 3 Taylor Swift Songs : </td> <td> <select name="1" size="4" multiple> <optgroup label="Taylor Swift"> <option value="Our Song" selected="selected">Our Song</option> <option value="Tim McGraw">Tim McGraw</option> <option value="Picture To Burn">Picture To Burn</option> </optgroup> </select></td> </td> </tr> <tr> <td colspan = 2> <div align="center"><input type=button value="Submit"></div> </td> </tr> </table> </div> </body> </html>

CSS STYLING body {background-image: url('tay.jpg'); font-family : verdana;} table {font-family: arial; font-size: medium; color: #00CCFF; width: 100%;} judul {font-weight : bolder; font-size: x-large; color: #00FFFF;} td{padding:5px;} .right {text-align: right} td.pict {colspan: 2; height:"107"; width:"295"} div.head {width: 100%; background-image: url('blackTransparent.png')} div.body {width: 50%; color: #00CCFF; font-size: small; background-image: url('blackTransparent.png'); align:"center"; float: left; margin-top: 15; marginbottom: 15; padding: 10;} a.blue {color: #00FFFF ; text-decoration: none;} a.white {color: white ; text-decoration: none; font-weight : bold;} div.pict { float: left; margin-top: 15; margin-bottom: 15; padding: 10; background-image: url('blackTransparent.png');}

VALIDASI EMAIL <script type="text/javascript"> function validateForm() { var x=document.forms["register"]["email"].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } } </script> <form name="register" onsubmit="return validateForm();" method="post"> SHOPPINGCART.PHP if (isset($_GET["q"])) { //insert if ($_GET["q"] == "insert") { $id = $_GET["id"]; if(isset($_COOKIE["cart"][$id])) //kalau udah pernah pilih (buku ada dalam cart) buka yang sama, increment jumlahnya { $jum = $_COOKIE["cart"][$id] + 1; setcookie("cart[$id]",$jum,time()+86400); } else //barang yang dipilih belom ada di cart { setcookie("cart[$id]",1,time()+86400); //cart adalah nama cookie(array), dengan index $id, diisi default jumlah 1 }} //update if ($_GET["q"] == "update") { foreach($_GET as $i=>$j) { if($i!="q") { if($j==0) setcookie("cart[$i]",0,time()-86400); //supaya expired else setcookie("cart[$i]",$j,time()+86400); }}} //empty cart if ($_GET["q"] == "empty") { foreach($_COOKIE["cart"] as $i=>$j) { setcookie("cart[$i]",0,time()-86400); //supaya expired }}} header("location:viewcart.php");

VIEWCART.PHP session_start(); include "includes/header.php"; include "includes/connect.php"; include "includes/functions.php"; if(isset($_COOKIE["cart"])) //kalau cart ada { echo "<a href=shoppingcart.php?q=empty>Empty Cart</a>"; echo "<form action=shoppingcart.php method=get>"; //UNTUK PROSES echo "<table border=1 cellpadding=10>"; echo "<tr> <td>Kode Buku</td> <td>Judul Buku</td> <td>Harga Satuan</td> <td>Jumlah</td> <td>Subtotal</td> </td>"; foreach($_COOKIE["cart"] as $i=>$j) //index masuk ke i, isi index masuk ke j { $query = "SELECT * FROM book WHERE ID='$i'"; $hasil = mysql_query($query, $con); $brs = mysql_fetch_array($hasil); $judul = $brs["TITLE"]; $harga = $brs["PRICE"]; $subtotal = $j * $harga; echo "<tr> <td>$i</td>"; echo "<td>$judul</td> <td>$ $harga</td> <td><input type=text size=10 value=$j name=$i></td> <td>$ $subtotal</td>"; echo "</tr>"; } echo "</table>"; echo "<input type=hidden name='q' value='update'> <input type=submit value=Update>"; echo "</form>"; } Else echo "<H1> Cart is Empty </H1>" HEADER LAPORAN TRANSAKSI $link = $db->open_connection(); $query = "SELECT h.hpel_id, h.hpel_tgl, u.pel_username, m.men_nama, d.dpel_jmlh, m.men_harga, d.dpel_jmlh*m.men_harga FROM ".$basdat['prefix']."hpembelian h, ".$basdat['prefix']."dpembelian d, ".$basdat['prefix']."menu m, ".$basdat['prefix']."user_admin u WHERE h.pel_username = u.pel_username AND h.hpel_id = d.hpel_id AND d.men_id = m.men_id ORDER BY h.hpel_id ASC, u.pel_username ASC"; $result = mysql_query($query) or die (mysql_error()); $jumlah = mysql_num_rows($result); if ($jumlah >= 1) { $kolom = mysql_num_fields($result); echo "<table border='1'>"; echo "<tr class=header><td>ID Transaksi</td><td>Tanggal Transaksi</td><td>Username</td><td>Menu</td><td>Jumlah</td><td>Harga Satuan</td><td>Total</td></tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; for ($i=1;$i<=$kolom;$i++) { echo "<td>"; echo $row[$i-1]." "; echo "</td>"; } echo "</tr>"; } echo "</table>"; } else { echo "Tidak ada data ditemukan."; } mysql_close($link);

PROSESLOGIN.PHP session_start(); include "includes/connect.php"; if(isset($_POST["username"]) && isset($_POST["password"])) { $username = $_POST["username"]; $password = $_POST["password"]; $query = "SELECT * FROM user WHERE username='$username' AND password='$password'"; $hasil = mysql_query($query,$con); if(mysql_num_rows($hasil) == 1) { $isi = mysql_fetch_array($hasil); $_SESSION["level"]=$isi["level"]; $_SESSION["username"]=$username; } header("location:katalog.php"); } PROSESLOGOUT.PHP session_start(); unset($_SESSION["username"]); unset($_SESSION["password"]); unset($_SESSION["level"]); header("location:katalog.php"); PROSESREGISTER.PHP include "includes/connect.php"; if (isset($_POST['submit'])) { $e = array(); //print_r($p); if(empty($_POST['username'])) { $e[] = 'You must have a username'; } else if($_POST['pass'] !== $_POST['cpass']) { $e[] = 'Passwords did not match'; } else if(strlen($_POST['pass'])<3) { $e[] = 'Passwords are minimal 3 characters long'; } else { $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['pass']); $email = mysql_real_escape_string($_POST['email']); $sql = "INSERT INTO USER(username, email, password, level) VALUES('".$username."','".$email."','".$pass."',2)"; if($res = mysql_query($sql)) { header("location:katalog.php"); } else { $e[] = "Username unavailable. Please choose another username."; }} //header("location:katalog.php") //$result = mysql_query($sql) or die(mysql_error()); foreach($e as $err) { echo "<div class=error>$err</div>"; }}

PROSESSEARCH.PHP session_start(); include "includes/header.php"; include "includes/connect.php"; include "includes/functions.php"; if (isset($_GET["q"])) { $q=$_GET["q"]; if($q == "") header("location:katalog.php") } else header("location:katalog.php"); if(isset($_GET["page"])) $page = $_GET["page"]; else $page = 1; $page_size = 20; $page_start = ($page-1)*$page_size; $page_end = $page_start+$page_size-1; echo "Halaman $page <br/><br/>"; //mengambil banyaknya jumlah data dalam tabel $kuerihitung = "SELECT COUNT(*) FROM book WHERE TITLE LIKE '%$q%'"; $hasilhitung = mysql_query($kuerihitung, $con); $hasil = mysql_fetch_array($hasilhitung); $jmlhdata = $hasil[0]; $query = "SELECT * FROM book WHERE TITLE LIKE '%$q%' limit $page_start, $page_size"; $hasil = mysql_query($query,$con); $i = 0; start_table(); while ($brs = mysql_fetch_array($hasil)) { book_simple($i+$page_start, $brs); $i++; } end_table(); $page_count = ceil($jmlhdata/$page_size); //tambah combobox echo "<form action=search.php method=get> <select name=page>"; //BELOM SEMPURNA for($j=1;$j<=$page_count;$j++) { echo "<option value=$j>$j</option>"; } echo"<input type=hidden name=q value=$q>"; echo "</select><input type=submit></form><br />"; //combobox sampe sini if($page>1) { $prev = $page-1; echo "<a href=search.php?q=$q&page=1>First</a> "; echo "<a href=search.php?q=$q&page=". $prev . ">Prev</a> "; } for($j=1;$j<=$page_count;$j++) { if($j == $page) echo "$j "; else echo "<a href=search.php?q=$q&page=$j>$j</a> "; } if($page<$page_count) { $next = $page+1; echo "<a href=search.php?q=$q&page=". $next . ">Next</a> "; echo "<a href=search.php?q=$q&page=$page_count>Last</a> "; } echo "<br/><br />"; include "includes/footer.php";

include "includes/constant.php"; //connect.php $con = mysql_connect(DB_ServerName, DB_UserName, DB_Password); if (!$con) die("Error koneksi"); $r = mysql_select_db(DB_DatabaseName, $con); if (!$r) die("Error selecting database"); Constant.php <?php define("DB_ServerName", "localhost"); ?> Functions.php

forminsert.php session_start(); include "includes/header.php"; include "includes/connect.php"; include "includes/functions.php"; start_table(); detail_inputkosong(); end_table(); echo "<br/><br/>"; include "includes/footer.php"; formdelete.php

prosesdelete.php session_start(); include "includes/connect.php"; if(isset($_SESSION["level"]) and $_SESSION["level"]==0) { $id = $_POST["id"]; $query = "DELETE FROM book WHERE ID='$id'"; mysql_query($query,$con); header("location:katalog.php"); }

function detail_input($baris) { echo "<form action=prosesedit.php method=post>"; echo "<tr>"; echo "<td rowspan=6 align=center>"; echo "<img src='img/".$baris['ID'].".jpg' border=0>"; echo "</td>"; echo "<td class=title>Title : <input type=text name=title value ='".$baris['TITLE']."'> </td></tr>"; echo "<tr><td class=author> Author : <input type=text name=author value ='".$baris['AUTHOR']."'></td></tr>"; echo "<tr><td> Publisher : <input type=text name=publisher value ='".$baris['PUBLISHER']."'></td></tr>"; echo "<tr><td class=price>Price : $<input type=text name=price value =".$baris['PRICE']."></td></tr>"; echo "<tr><td> Published on <input type=text name=year value ='".$baris['YEAR']."'></td></tr>"; echo "<tr><td> <span style='font-weight:bold; color:darkblue;'> Sinopsis : </span><br/><textarea name=sinopsis cols='50' rows='10'>".$baris['REVIEW']."</textarea><br> <input type=submit value=Save> </td></tr>"; echo "<input type=hidden name=id value=".$baris['ID']."></form>"; } FORMEDIT.PHP session_start(); include "includes/header.php"; include "includes/connect.php"; include "includes/functions.php"; if (isset($_GET["id"])) { $id=$_GET["id"]; if($id == "") header("location:katalog.php"); } Else header("location:katalog.php"); $query = "SELECT * FROM book where ID='$id'"; $hasil = mysql_query($query,$con); $baris = mysql_fetch_array($hasil); start_table(); detail_input($baris); end_table(); echo "<br/><br/>"; include "includes/footer.php";

session_start(); include "includes/header.php"; include "includes/connect.php"; include "includes/functions.php"; if (isset($_GET["id"])) { $id=$_GET["id"]; if($id == "") header("location:katalog.php"); } else header("location:katalog.php"); $query = "SELECT * FROM book where ID='$id'"; $hasil = mysql_query($query,$con); $baris = mysql_fetch_array($hasil); start_table(); detail_simple($baris); end_table(); echo "<br/><br/>"; echo "<form action='prosesdelete.php' method=post><input type=hidden name=id value=$id>Are you sure? <input type=submit value='Yes, delete this book'></form>"; echo "<form action='katalog.php'><input type=submit value=Back></form>"; include "includes/footer.php";

Prosesedit.php session_start(); include "includes/connect.php"; if(isset($_SESSION["level"]) and $_SESSION["level"]==0) { $title = $_POST["title"]; $author = $_POST["author"]; $publisher = $_POST["publisher"]; $price = $_POST["price"]; $year = $_POST["year"]; $sinopsis = $_POST["sinopsis"]; $id = $_POST["id"]; $query = "UPDATE book SET TITLE='$title', AUTHOR='$author', PUBLISHER='$publisher', PRICE=$price, YEAR=$year, REVIEW='$sinopsis' WHERE ID='$id'"; mysql_query($query,$con); header("location:detail.php?id=$id"); }