BAB V KESTMPULAN DAN SAPAN
BAB VT TMPLEMENTAST
4.2 Tmplementasi Proses
Proses dalam sistem dilihat dari 3 sisi yaitu sisi administrator, sisi anggota dan sisi user biasa.
Listing program untuk membuka koneksi dengan database yang disimpan dengan nama konek.php
<?
$connect=mysql_connect("localhost","","") or die ("gagal masuk
database");
mysql_select_db("template",$connect) or die ("gagal");
?>
a. Implementasi proses dari sisi user biasa Fasilitas pencarian produk
User memasukkan kata kunci berupa nama kategori produk. Kemudian sistem akan menampilkan data-data produk berdasarkan kata kunci pencarian. Listing program terdapat dalam file search.php
<? include("konek.php"); ?>
<link href="content.css" rel="stylesheet" type="text/css">
<table height="500" border="0" cellpadding="4" cellspacing="0">
<tr valign="top">
<td width="566" align="left">
<table width="182" border="0" cellpadding="0" cellspacing="1"
bgcolor="#ffcc00">
<td height="24" width="24"><img src="img/arrow-org.gif"></td>
<td bgcolor="#FFFFFF" class="menu" width="155">Search Product</td>
</tr>
</table><br>
<table background="img/back.jpg" width="500" border="0" align="center"
cellpadding="4" cellspacing="0" bgcolor="#FFFFFF" class="genmed">
<td colspan="4" align="center"
background="img/bg-title.gif"> </td>
<tr align="center" bgcolor="#7B82DD" height="26" class="white-bold">
<td width="66" bgcolor="#7B82DD">Gambar</td>
<td width="149" bgcolor="#7B82DD">Nama Produk</td>
<td width="105" bgcolor="#7B82DD">Kategori</td>
<td width="148" bgcolor="#7B82DD">Perusahaan</td>
</tr>
<?
$qr_jd=mysql_query("select a.*, b.id_anggota, b.perusahaan from produk a,
anggota b where a.id_anggota=b.id_anggota and a.kategori like
'%$kategori%'"); while($row_jd=mysql_fetch_array($qr_jd)) { ?> <tr valign="top" class="menu"> <td width="66"> <? if(!empty($row_jd[gambar])) {
echo "<img src=\"img/$row_jd[gambar]\" alt=\"$row_jd[gambar]\"
border=\"0\" width=\"40\" height=\"40\">";
}
else
{
echo "NO PICTURES AVAILABLE";
}
?> </td>
<td width="149" valign="middle" >
<p><a href="profil.php?perintah=detail&id_anggota=<? echo
strtoupper($row_jd[id_anggota]);?>&id_produk=<? echo
strtoupper($row_jd[id_produk]) ;?>" class="forumlink"><? echo
strtoupper($row_jd[namaproduk]) ;?> </a></td>
<td width="105" valign="middle" ><? echo
<td width="148" valign="middle"><p><? echo
strtoupper($row_jd[perusahaan]) ;?> </td>
</tr>
<tr>
<td colspan="4"><? echo "<hr size=\"1\" color=\"#ffcc00\">";?></td>
</tr> <? } ?> <tr height="27" class="menu"> <td background="img/bg-title.gif" colspan="4"> </td> </tr> </table> </td> <td width="14"> </td> </tr> </table>
Fasilitas pengisian buku tamu
Listing program untuk pengisian buku tamu pada form buku tamu yang terdapat dalam file guestbook.php
<form action="addguest.php" method="post">
<table background="img/back.jpg" width="400" border="0" cellpadding="4"
cellspacing="1" bgcolor="#666666" class="genmed">
<tr height="27">
<td align="center" background="img/bg-title.gif" class="menu" colspan="2">SIGN GUESTBOOK</td>
</tr> <?
$qr_guest=mysql_query("select max(idguest) as kode_guest from bukutamu");
$row_guest=mysql_fetch_array($qr_guest);
?>
<tr>
<td width="300"><input type="text" name="nama" size="40"></td>
</tr> <tr>
<td align="right">E-mail</td>
<td><input type="text" name="email" size="40"></td> </tr>
<tr>
<td align="right">Alamat</td>
<td><input type="text" name="alamat" size="40"></td>
</tr>
<tr valign="top">
<td align="right">Pesan</td>
<td><textarea name="pesan" cols="40" rows="10"></textarea></td> </tr>
<tr height="27">
<td align="right" background="img/bg-title.gif" colspan="2">
<input type="hidden" name="<?="kode";?>"
value="<?=$row_guest[kode_guest]+1;?>">
<input type="hidden" name="<?="tanggal";?>" value="<?=date("Y-m-d");?>">
<input type="submit" name="Submit" value="Tambah"> <input type="reset" name="Reset" value="Reset"> </td>
</tr> </table> </form>
<table width="150" border="0" cellpadding="0" cellspacing="1"> <tr valign="middle">
<td><img src="img/view.jpg"></td>
<td class="menu"> <a href="index.php?aksi=bukutamu" class="menu">Lihat Buku Tamu</a></td>
</tr> </table> <p> </p> </td> </tr> </table>
Berikut ini adalah listing program untuk menyimpan data tamu yang tersimpan dalam file addguest.php
include("konek.php");
if(!$nama || !$email || !$alamat || !$pesan) {
print("<script>window.alert('Maaf, semua data harus anda isikan');window.history.back();</script>");
}
elseif(ereg("^.+@.+\\..+$",$email)!=true) {
print("<script>window.alert('Format penulisan e-mail yang anda masukkan salah');window.history.back(-1);</script>");
} else {
mysql_query("insert into bukutamu values('$kode','$nama','$alamat','$email','$pesan','$tanggal','$id')");
print("<script>window.alert('Buku tamu dari \"$nama\" telah ditambahkan !
');window.location='index.php?aksi=bukutamu';</script>");
}
?>
Fasilitas lihat buku tamu
<table height="500" border="0" cellpadding="4" cellspacing="0">
<tr valign="top">
<td width="625"><table width="130" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffcc00">
<tr>
<td height="24" width="24"><img src="img/arrow-org.gif"></td>
<td bgcolor="#FFFFFF" class="menu" width="106"> Buku Tamu </td>
</tr> </table>
<table width="130" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffcc00">
<tr>
<td height="24" width="24"><img src="img/arrow-org.gif"></td>
<td bgcolor="#FFFFFF" class="menu" width="106"> <a
href="index.php?aksi=isitamu">Tambah</a></td>
</tr>
</table>
<table background="img/back.jpg" width="500" border="0" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF" class="gensmall">
<td width="200" background="img/bg-title.gif">Sender</td> <td width="200" background="img/bg-title.gif">Message</td> </tr> <? if(empty($awal)) $awal=0;
$qr_guest=mysql_query("select * from bukutamu order by tgl desc limit $awal,5"); while($row_guest=mysql_fetch_array($qr_guest)) { ?> <tr valign="top"> <td><?
echo "From: ".$row_guest[nama]."<br>";
echo "E-mail: <a
href=mailto:$row_guest[email]>$row_guest[email]</a><br>"; ?> </td> <td> <? echo "Message:<br>"; echo $row_guest[pesan]; ?> </td> </tr> <tr> <td colspan="2"><?
echo "Address: ".$row_guest[alamat]."<br>"; echo "Posted on: ".$row_guest[tgl]."<br>"; ?></td>
</tr> <tr>
<td colspan="2"><? echo "<hr size=\"1\" color=\"#ffcc00\">";?></td> </tr> <? } ?> <tr class="menu"> <td colspan="2"><?
$qr_book=mysql_query("select * from bukutamu "); $jumlah=mysql_num_rows($qr_book); $i=$jumlah/5; $i=ceil($i); echo "Page: "; for($j=1;$j<=$i;$j++) { $awal=(($j-1) * 4+$j)-1;
print("[ <a href=index.php?aksi=bukutamu&awal=$awal&halaman=$j> $j</a> ] \n"); } ?> </td> </tr> </table>
<? echo "<a href=\"index.php?aksi=\" class=\"red\">Back</a>";?> </td> </tr>
</table>
Fasiltas lihat produk dan daftar perusahaan
Listing program untuk melihat galery produk yang ada terdapat dalam file produk.php.
<p align="center" class="gen">Galery Produk</p>
<table width="400" border="0" align="center" cellpadding="4" cellspacing="1"
bgcolor="#FFFFFF" class="genmed">
<tr align="center" bgcolor="#7B82DD" height="26" class="white-bold"> <td width="87">Gambar</td> <td width="115">Nama Produk</td> <td width="50">Harga</td> <td width="94">Kategori</td> <td width="50">Jumlah</td> </tr> <? if(empty($awal)) $awal=0;
$qr_produk=mysql_query("select * from produk order by id_produk desc limit $awal,20");
while($row_produk=mysql_fetch_array($qr_produk)) {
?>
<tr bgcolor="#EBECFA" valign="top">
<td width="168" align="center" valign="middle"><? if(!empty($row_produk[gambar]))
{
echo "<img src=\"../img/$row_produk[gambar]\" alt=\"$row_produk[gambar]\" border=\"0\" width=\"40\">";
else {
echo "NO PICTURES AVAILABLE"; } ?> <td> <?=$row_produk[namaproduk];?></td> <td align="right"> <?=$row_produk[harga];?> <div align="center"></div></td> <td><?=$row_produk[kategori];?></td> <td align="center"><?=$row_produk[jumlah];?> </td> </tr> <? } ?> </table>
Listing program untuk melihat daftar anggota yang terdapat dalam file tampil_anggota.php
<?
$qr_jd=mysql_query("select * from anggota where status='A'");
while($row_jd=mysql_fetch_array($qr_jd))
{?> <? } ?>
<tr align="center" bgcolor="#FFCC00" height="26" class="white-bold">
<td width="233">Nama Perusahaan </td>
<td width="250">Alamat</td>
</tr>
<?
$qr_jd=mysql_query("select * from anggota where status='A'");
while($row_jd=mysql_fetch_array($qr_jd)) { ?> <tr valign="top" class="menu"> <td width="29"> <?
{
echo "<img src=\"imgmbr/$row_jd[logo]\" alt=\"$row_jd[logo]\" border=\"0\" width=\"40\" height=\"40\">";
} else {
echo "NO PICTURES AVAILABLE"; }
?> </td>
<td width="205" valign="middle" >
<p><a href="profil.php?id_anggota=<? echo strtoupper($row_jd[id_anggota]) ;?>" class="menu"><? echo strtoupper($row_jd[perusahaan]) ;?> </a></td>
<td width="250" valign="middle">
<p><? echo strtoupper($row_jd[alamat]) ;?> </td> </tr>
<tr>
<td colspan="3"><? echo "<hr size=\"1\" color=\"##FF0000\">";?></td> </tr>
<? } ?>
Fasilitas pendaftaran anggota
Pada proses ini calon anggota mengisi formulir pendaftaran. Listing program disimpan dalam file reg.php
<?
include("konek.php");
include("header.php");
?>
<table width="221" border="0" cellpadding="0" cellspacing="1"
bgcolor="#ffcc00">
<tr>
<td height="24" width="24"><img src="img/arrow-org.gif"></td>
<td bgcolor="#FFFFFF" class="menu" width="194"> Form Registrasi</td>
</tr>
</table>
<form action="proses.php?aksi=registrasi" method="post">
<table width="603" border="0" align="center" cellpadding="4"
cellspacing="1" bgcolor="#FFFFFF" class="gen">
<tr align="center" bgcolor="#7B82DD" class="genwhite">
<td colspan="2"><b>Form Registrasi </b></td>
</tr> <?
$query=mysql_query("select max(id_anggota) as mid_anggota from anggota"); $row_film=mysql_fetch_array($query); ?> <tr bgcolor="#EBECFA"> <td width="153">ID Member</td> <td width="431"> <?=$row_film[mid_anggota]+1;?> [otomatis]
<input type="hidden" name="id_anggota"
value="<?=$row_film[mid_anggota]+1;?>"></td>
</tr>
<tr bgcolor="#EBECFA">
<td>Nama Perusahaan</td>
<td><input type="text" name="perusahaan" size="50"></td>
</tr>
<tr bgcolor="#EBECFA">
<td>Alamat</td>
<td><input type="text" name="alamat" size="50"> </td>
</tr>
<tr bgcolor="#EBECFA">
<td>Telepon</td>
<td><input type="text" name="telpon" size="25"></td>
</tr>
<tr bgcolor="#EBECFA">
<td>Pemilik</td>
<td><input type="text" name="pemilik" size="50"> </td>
</tr>
<tr bgcolor="#EBECFA">
<td>Email</td>
<tr bgcolor="#EBECFA">
<td>User Name</td>
<td><input type="text" name="username" size="25"></td>
</tr>
<tr bgcolor="#EBECFA">
<td>Password</td>
<td><input type="password" name="password" size="25" c></td>
</tr>
<tr bgcolor="#EBECFA">
<td>Logo</td>
<td><input type="file" name="gambar" size="40"> </td>
</tr> <tr bgcolor="#EBECFA"> <td colspan="2"> </td> </tr> <tr bgcolor="#EBECFA"> <td colspan="2"></td> </tr> <tr bgcolor="#7B82DD"> <td align="right" colspan="2">
<input type="submit" name="add" value="Add"> <input type="reset" name="reset" value="Reset">
<input type="reset" value="Back" onClick="Javascript:window.history.back()"> </td> </tr> </table> </form> <? include("footer.php"); ?>
Kemudian data registrasi akan disimpan dalam file proses.php <? include("konek.php"); switch($aksi) { case"registrasi": {
if(!$perusahaan || !$alamat || !$telpon || !$pemilik || !$email || ! $username || !$password || !$gambar)
{ print("<script>window.alert('Isian Belum Lengkap.');window.history.back();</script>"); } else { $gambar_name=basename($gambar); if(is_file($gambar)) { copy($gambar,"imgmbr/$gambar_name"); $gambar=$gambar_name; }
mysql_query("insert into anggota (id_anggota, perusahaan,alamat,telpon,pemilik,email,username,password,logo) values('$id_anggota','$perusahaan','$alamat','$telpon','$pemil ik','$email', '$username','$password','$gambar')"); print("<script>window.alert('Daftar anggota..Sukses.');window.location='index.php';</script>"); } } break; } ?>
b. Implementasi dari sisi anggota Fasilitas update data
a. Fasilitas update untuk tambah data
Berikut ini adalah salah satu listing program untuk menambah data produk yang tersimpan dalam file anggota_proses.php
case"tbhproduk":
{
$query=mysql_query("select status from anggota where
id_anggota='$id_anggota'");
$result=mysql_fetch_array($query); if($result[status]=='Aktif') {
$query=mysql_query("select * from produk where id_produk='$id_produk'");
$result=mysql_fetch_row($query); if($result>0)
{
...');window.history.back();</script>"); }
else {
if(!$id_produk || !$namaproduk || !$kategori || !$harga || !$jumlah || !$deskripsi || !$gambar )
{ print("<script>window.alert('Isian Belum Lengkap.');window.history.back();</script>"); } else { $gambar_name=basename($gambar); if(is_file($gambar)) { copy($gambar,"img/$gambar_name"); $gambar=$gambar_name; }
mysql_query("insert into produk values('$id_produk','$kategori','$namaproduk','$harga','$jumlah' ,'$gambar','$id_anggota','B','$deskripsi')"); print("<script>window.alert('Tambah Produk..Sukses.');window.location='member.php?aksi=produk';</s cript>"); } } } else {
print("<script>window.alert('Status anda belum
aktif...');window.history.back();</script>");
} } break;
b. Fasilitas update untuk edit data
Berikut ini adalah salah satu listing program untuk mengedit data produk dan profile anggota yang tersimpan dalam file amggota_proses.php
$query=mysql_query("select status from anggota where id_anggota='$id_anggota'");
$result=mysql_fetch_array($query); if($result[status]=='Aktif')
{
mysql_query("update produk set
namaproduk='$namaproduk',harga='$harga',jumlah='$jumlah',kategori='$kat
egori',keterangan='$keterangan, deskripsi='$deskripsi' where
id_produk='$id_produk'");
print("<script>window.alert('Update data produk Sukses ...');window.location='member.php?aksi=produk';</script>");
} else
{
print("<script>window.alert('Status anda belum aktif...');window.history.back();</script>"); } } break; case"delproduk": {
$query=mysql_query("select status from anggota where id_anggota='$id_anggota'");
$result=mysql_fetch_array($query);
if($result[status]=='Aktif')
{
mysql_query("delete from produk where id_produk='$id_produk'");
print("<script>window.alert('Data produk telah terhapus...');window.location='member.php?aksi=produk';</script>");
} else
{
print("<script>window.alert('Status anda belum aktif...');window.history.back();</script>"); } } break; case"editprofil": {
$query=mysql_query("select status from anggota where id_anggota='$id_anggota'");
{
if(!$username || !$perusahaan || !$alamat || !$telpon || !$pemilik || !$email) { print("<script>window.alert('Isian Belum Lengkap.');window.history.back();</script>"); } else {
mysql_query("update anggota set username='$username',perusahaan='$perusahaan',alamat='$alamat',
telpon='$telpon',pemilik='$pemilik',email='$email',
thn_berdiri='$thn_berdiri', detail='$detail' where id_anggota='$id_anggota'"); if($ceklogo=='ganti') { $gambar_name=basename($gambar); if(is_file($gambar)) { copy($gambar,"imgmbr/$gambar_name"); $gambar=$gambar_name; }
mysql_query("update anggota set logo='$gambar' where
id_anggota='$id_anggota'");
print("<script>window.alert('Update data dan logo Sukses ...');window.location='member.php?aksi=profil';</script>"); } else { print("<script>window.alert('Update Sukses ...');window.location='member.php?aksi=profil';</script>"); } } } else {
print("<script>window.alert('Status anda belum aktif...');window.history.back();</script>");
} }
c. Fasilitas update untuk hapus data
Berikut ini adalah salah satu listing program untuk menghapus data produk yang tersimpan dalam file anggota_proses.php
case"delproduk":
{
$query=mysql_query("select status from anggota where id_anggota='$id_anggota'");
$result=mysql_fetch_array($query); if($result[status]=='Aktif') {
mysql_query("delete from produk where id_produk='$id_produk'");
print("<script>window.alert('Data produk telah terhapus...');window.location='member.php?aksi=produk';</ script>");
} else
{
print("<script>window.alert('Status anda belum aktif...');window.history.back();</script>");
} }
break;
d. Fasilitas update untuk ganti password case"gantipwd":
{
$query=mysql_query("select status from anggota where
id_anggota='$id_anggota'");
$result=mysql_fetch_array($query);
if($result[status]=='Aktif')
{
$query=mysql_query("select username, password from anggota where
id_anggota='$id_anggota'");
$result=mysql_fetch_array($query);
{
mysql_query("update anggota set password='$newpwd'
where id_anggota='$id_anggota'");
$password=$newpwd;
print("<script>window.alert('Ganti Password Sukses
...');window.location='member.php?aksi=profil';</script>");
} else
{
print("<script>window.alert('Password lama tidak sama...');window.history.back();</script>");
} } else
{
print("<script>window.alert('Status anda belum aktif...');window.history.back();</script>");
} } break;
Fasilitas memilih template case"pilihtmp":
{
$query=mysql_query("select status from anggota where
id_anggota='$id_anggota'");
$result=mysql_fetch_array($query);
if($result[status]=='Aktif')
{ mysql_query("update anggota set
id_template='$id_template' where
id_anggota='$id_anggota'");
print("<script>window.alert('Pilih Template Sukses
...');window.location='member.php?aksi=template';</scri
pt>");
}
else {
print("<script>window.alert('Status anda belum aktif...');window.history.back();</script>");
} } break;
Fasilitas untuk mengirim pesan ke admin case"kontak": { print $id_pesan; if(!$pesan || !$jenis) { print("<script>window.alert('Isian Belum Lengkap.');window.history.back();</script>"); } else {
mysql_query("insert into pesan
values('$id_pesan','$id_anggota','$pesan','$tgl_pesan','$jenis ','M')"); print("<script>window.alert('Sukses terkirim...');window.location='member.php?aksi=kontak';</scrip t>"); } } break;
c. Implementasi proses dari sisi administrator 1. Proses Login Adminitrator
Proses ini digunakan untuk mengecek kevalidan data administrator. Pihak administator memasukkan id_admin dan password pada form login yang telah