Lampiran v2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

LAMPIRAN - LAMPIRAN SOURCE CODE FRONTEND

Input data relawan.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>RELAWAN</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="simpan-data-relawan.php" method="post" enctype="multipart/form-data" name="FMHS"> <table width="780" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#cc0000"> <tr> <td height="40" align="center" bgcolor="#cc0000"></td> <center> <img src="relawan.jpg"></center> </tr> <tr><td height="40" align="center" bgcolor="#red"><strong><font color="#FFFFFF">FORMULIR RELAWAN DEMI INDONESIA</font></strong></td> </tr> <tr> <td bgcolor="#FFFFFF"><table width="452" border="0" align="center" cellpadding="5" cellspacing="0"> <tr><td>Nama Lengkap</td><td>:</td> <td><input name="nama" type="text" id="nama" size="30" maxlength="30"></td> </tr> <tr><td>Tempat Lahir</td><td>:</td> <td><input name="tempat_lahir" type="text" id="tempat_lahir" size="30" maxlength="30"></td> </tr> <tr><td>Tanggal Lahir</td><td>:</td> <td><select name="tgl" size="1" id="tgl"> <?php for ($i=1;$i<=31;$i++) { echo "<option value=".$i.">".$i."</option>"; } ?> </select> <select name="bln" size="1" id="bln"> <?php $bulan=array("","Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Okt ober","November","Desember"); for ($i=1;$i<=12;$i++) { echo "<option value=".$i.">".$bulan[$i]."</option>";

100

} ?> </select> <select name="thn" size="1" id="thn"> <?php for ($i=1985;$i<=2000;$i++) { echo "<option value=".$i.">".$i."</option>"; } ?> </select></td> </tr> <tr><td>Jenis Kelamin</td><td>:</td> <td><input name="jenis_kelamin" type="radio" value="L" checked> Laki-laki <input name="jenis_kelamin" type="radio" value="P"> Perempuan </td> </tr> <tr> <tr><td width="113">Nomor KTP</td><td width="30">:</td> <td width="237"><input name="no_ktp" type="text" id="no_ktp" size="30" maxlength="12"></td> </tr> <tr><td>Agama</td><td>:</td> <td><input name="agama" type="text" id="agama" size="30" maxlength="30"></td> </tr> <tr><td>Pekerjaan</td><td>:</td> <td><input name="pekerjaan" type="text" id="pekerjaan" size="30" maxlength="30"></td> </tr> <tr><td>Pendidikan terakhir</td><td>:</td> <td><input name="pt" type="text" id="pt" size="30" maxlength="30"></td> </tr> <td>Alamat</td> <td>:</td> <td><textarea name="alamat" cols="30" rows="5" id="alamat"></textarea></td> </tr> <tr><td>Kelurahan/Desa</td><td>:</td> <td><input name="kel" type="text" id="kel" size="30" maxlength="30"></td> </tr> <tr><td>Kabupaten/Kota</td><td>:</td> <td><input name="kota" type="text" id="kota" size="30" maxlength="30"></td> </tr> <tr><td>Provinsi</td><td>:</td> <td><input name="prov" type="text" id="prov" size="30" maxlength="30"></td> </tr> <tr><td>Kode Pos</td><td>:</td> <td><input name="kp" type="text" id="kp" size="30" maxlength="30"></td> </tr> <td>Telepon</td> <tr><td width="113">Rumah</td><td width="30">:</td> <td width="237"><input name="rumah" type="text" id="rumah" size="30" maxlength="12"></td> </tr>

101

<tr><td width="113">Handphone</td><td width="30">:</td> <td width="237"><input name="hp" type="text" id="hp" size="30" maxlength="12"></td> </tr> <tr><td width="113">PIN BB</td><td width="30">:</td> <td width="237"><input name="pin" type="text" id="pin" size="30" maxlength="12"></td> </tr> <tr><td width="113">Email</td><td width="30">:</td> <td width="237"><input name="email" type="text" id="email" size="30" maxlength="12"></td> </tr> <td>Motivasi</td> <td>:</td> <td><textarea name="mot" cols="30" rows="5" id="mot"></textarea></td> </tr> <td>Rekomendasi</td> <td>:</td> <td><textarea name="rek" cols="30" rows="5" id="rek"></textarea></td> </tr> <tr><td>Photo</td><td>:</td> <td><input type="file" name="fupload" id="fupload"></td> </tr> <tr><td colspan="3" align="center"><input name="fok" type="submit" id="fok" value="OK"> <input name="fulang" type="reset" id="fulang" value="Ulangi"> <input name="fulang2" type="button" id="fulang2" value="Batal" onClick="javascript:history.back()"></td> </tr> </table></td> </tr> </table> </form> <div align="center"><a href="index.php">Menu Utama</a></div> </body> </html>

Koneksi.php <?php session_start(); ob_start(); $dbserver="localhost"; $dbusername="root"; $dbpassword=""; $dbname="dblokomedia"; mysql_connect($dbserver,$dbusername,$dbpassword) or die(mysql_error()." Gagal koneksi server mysql"); mysql_select_db($dbname) or die (mysql_error()." Gagal koneksi database"); ?>

102

Simpan data relawan.php <?php include "koneksi.php"; $no_ktp=$_POST['no_ktp']; $nama=$_POST['nama']; $alamat=$_POST['alamat']; $tempat_lahir=$_POST['tempat_lahir']; $tanggal_lahir = $_POST['thn']."-".$_POST['bln']."-".$_POST['tgl']; $jenis_kelamin=$_POST['jenis_kelamin']; $agama=$_POST['agama']; $pekerjaan=$_POST['pekerjaan']; $pt=$_POST['pt']; $kel=$_POST['kel']; $kota=$_POST['kota']; $prov=$_POST['prov']; $kp=$_POST['kp']; $rumah=$_POST['rumah']; $hp=$_POST['hp']; $pin=$_POST['pin']; $email=$_POST['email']; $mot=$_POST['mot']; $rek=$_POST['rek']; $photo=$_POST['photo']; if (empty($no_ktp)) { die("Isikan NOMOR KTP!"); } elseif(empty($nama)) { die("Isikan Nama!"); } else { $cekdata="select no_ktp from relawan where no_ktp='$no_ktp'"; $ada=mysql_query($cekdata) or die(mysql_error()); if(mysql_num_rows($ada)>0) { die("Identitas telah Terdaftar!"); } else { if (!empty($_FILES["fupload"]["tmp_name"])) { $namafolder="../foto_relawan/"; //tempat menyimpan file $jenis_gambar=$_FILES['fupload']['type']; if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png") { $photo = $namafolder . basename($_FILES['fupload']['name']); if (!move_uploaded_file($_FILES['fupload']['tmp_name'],

103

$photo)) { die("Gambar gagal dikirim"); } } else { die("Jenis gambar yang anda kirim salah. Harus .jpg .gif .png"); } } //end if cek file upload mysql_query("insert into relawan(no_ktp,nama,alamat,tempat_lahir,tanggal_lahir,jenis_kelamin,agama,pekerjaan,pt,kel,k ota,prov,kp,rumah,hp,pin,email,mot,rek,photo) " . "values('$no_ktp','$nama','$alamat','$tempat_lahir','$tanggal_lahir','$jenis_kelamin','$a gama','$pekerjaan','$pt','$kel','$kota','$prov','$kp','$rumah','$hp','$pin','$email','$mot','$rek','$p hoto')") or die(mysql_error()); echo "Berhasil"; header("location:trims.php"); } //end if terdaftar } ?>

104

SOURCE CODE BACKEND

Index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>..::: Login Administrator :::..</title> <link rel="stylesheet" type="text/css" href="style_login.css" /> <link rel="shortcut icon" href="images/images_admin/favicon.ico" /> <script type="text/javascript"> function validasi(form){ if (form.username.value == ""){ alert("Anda belum mengisikan Username"); form.username.focus(); return (false); } if (form.password.value == ""){ alert("Anda belum mengisikan Password"); form.password.focus(); return (false); } return (true); } </script> </head> <body OnLoad="document.login.username.focus();"> <div id="main"> <!-- Header --> <div id="header"><img src="images/images_login/img_login_header.png" alt="Lokomedia" /></div> <!-- Middle --> <div id="middle"> <form id="form-login" name="login" method="post" action="cek_login.php" onSubmit="return validasi(this)"> <img src="images/images_login/img_login_user.png" align="absmiddle" class="img_user" /> <input type="text" name="username" size="29" id="input" /> <br />

105

<img src="images/images_login/img_login_pass.png" align="absmiddle" class="img_pass" /> <input type="password" name="password" size="29" id="input" /> <br /> <input name="Submit" type="image" value="Submit" src="images/images_login/button_login.png" id="submit" align="absmiddle" /> </form> </div> <!-- don't Change ;) --> <div class="clear"></div> <!-- Footer --> <div id="footer"> aaa</div> <!-- vertical_effect --> <div id="vertical_effect">&nbsp;</div> </div> </body> </html>

Aksi-relawan.php <?php session_start(); if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){ echo "<link href='style.css' rel='stylesheet' type='text/css'> <center>Untuk mengakses modul, Anda harus login <br>"; echo "<a href=../../index.php><b>LOGIN</b></a></center>"; } else{ include "../../../config/koneksi.php"; include "../../../config/library.php"; include "../../../config/fungsi_thumb.php"; $module=$_GET['module']; $act=$_GET['act']; // Hapus relawan if ($module=='relawan' AND $act=='hapus'){ $data=mysql_fetch_array(mysql_query("SELECT photo FROM relawan WHERE no_ktp='$_GET[id]'")); if ($data['photo']!=''){ mysql_query("DELETE FROM relawan WHERE no_ktp='$_GET[id]'"); unlink("../../../foto_relawan/$_GET[namafile]"); } else{

106

mysql_query("DELETE FROM relawan WHERE no_ktp='$_GET[id]'"); } header('location:../../media.php?module='.$module); } // Input relawan elseif ($module=='relawan' AND $act=='input'){ $lokasi_file = $_FILES['fupload']['tmp_name']; $tipe_file = $_FILES['fupload']['type']; $nama_file = $_FILES['fupload']['name']; // Apabila ada gambar yang diupload if (!empty($lokasi_file)){ if ($tipe_file != "image/jpeg" AND $tipe_file != "image/pjpeg"){ echo "<script>window.alert('Upload Gagal, Pastikan File yang di Upload bertipe *.JPG'); window.location=('../../media.php?module=relawan')</script>"; } else{ UploadRelawan($nama_file); mysql_query("INSERT INTO relawan(nama,alamat,photo) VALUES('$_POST[nama]','$_POST[alamat]','$nama_file')"); header('location:../../media.php?module='.$module); } } else{ mysql_query("INSERT INTO relawan(nama,alamat) VALUES('$_POST[nama]','$_POST[alamat]')"); header('location:../../media.php?module='.$module); } } // Update relawan elseif ($module=='relawan' AND $act=='update'){ $lokasi_file = $_FILES['fupload']['tmp_name']; $tipe_file = $_FILES['fupload']['type']; $nama_file = $_FILES['fupload']['name']; // Apabila gambar tidak diganti if (empty($lokasi_file)){ mysql_query("UPDATE relawan SET nama = '$_POST[nama]',alamat='$_POST[alamat]' WHERE no_ktp = '$_POST[id]'"); header('location:../../media.php?module='.$module); } else{ if ($tipe_file != "image/jpeg" AND $tipe_file != "image/pjpeg"){ echo "<script>window.alert('Upload Gagal, Pastikan File yang di Upload bertipe *.JPG'); window.location=('../../media.php?module=relawan')</script>"; } else{

107

UploadRelawan($nama_file); mysql_query("UPDATE relawan SET nama = '$_POST[nama]', alamat = '$_POST[alamat]', photo = '$nama_file' WHERE no_ktp = '$_POST[id]'"); header('location:../../media.php?module='.$module); } } } } ?>

Laporan-data-relawan.php <?php session_start(); if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){ echo "<link href='style.css' rel='stylesheet' type='text/css'> <center>Untuk mengakses modul, Anda harus login <br>"; echo "<a href=../../index.php><b>LOGIN</b></a></center>"; } else{ $aksi="modul/mod_relawan/aksi-relawan.php"; switch($_GET[act]){ // Tampil Relawan default: echo "<h2>Data Relawan</h2> <input type=button value='Tambah Data' onclick=location.href='?module=relawan&act=tambahrelawan'> <table class='list'><thead> <tr><td class='left'>no</td> <td class='left'>Photo</td> <td class='left'>Nama</td> <td class='left'>NO KTP</td> <td class='left'>Alamat</td> <td class='center'>aksi</td></tr></thead><tbody>"; $p = new Paging; $batas = 10; $posisi = $p->cariPosisi($batas); $tampil=mysql_query("SELECT * FROM relawan ORDER BY no_ktp DESC"); $no=$posisi+1; while ($r=mysql_fetch_array($tampil)){ echo "<tr><td class='left' width='25'>$no</td> <td class='left' width='120'><img src='../foto_relawan/kecil_$r[photo]'></td> <td class='left'>$r[nama]</td> <td class='left'><a href=$r[no_ktp] target=_blank>$r[no_ktp]</a></td> <td class='left'>$r[alamat]</td> <td class='center' width='85'><a href=?module=relawan&act=editrelawan&id=$r[no_ktp]><img src='images/edit.png' border='0'

108

title='edit' /></a> <a href='$aksi?module=relawan&act=hapus&id=$r[no_ktp]&namafile=$r[photo]'><img src='images/del.png' border='0' title='hapus' /></a> </tr>"; $no++; } echo "</tbody></table>"; break; case "tambahrelawan": echo "<h2>Tambah Relawan</h2> <form method=POST action='$aksi?module=relawan&act=input' enctype='multipart/formdata'> <table class='list'><tbody> <tr><td class='left'>Nama</td><td class='left'> : <input type=text name='nama' size=30></td></tr> <tr><td class='left'>No.Ktp</td><td class='left'> : <input type=text name='no_ktp' size=50></td></tr> <tr><td class='left'>Photo</td><td class='left'> : <input type=file name='fupload' size=40></td></tr> <tr><td class='left' colspan='2'><input type=submit value=Simpan> <input type=button value=Batal onclick=self.history.back()></td></tr> </tbody></table></form><br><br><br>"; break; case "editrelawan": $edit = mysql_query("SELECT * FROM relawan WHERE no_ktp='$_GET[id]'"); $r = mysql_fetch_array($edit); echo "<h2>Edit Banner</h2> <form method=POST enctype='multipart/form-data' action=$aksi?module=relawan&act=update> <input type=hidden name=id value=$r[no_ktp]> <table class='list'><tbody> <tr><td class='left'>Nama</td><td class='left'> : <input type=text name='nama' size=30 value='$r[nama]'></td></tr> <tr><td class='left'>Alamat</td><td class='left'> : <input type=text name='alamat' size=50 value='$r[alamat]'></td></tr> <tr><td class='left'>Photo</td><td class='left'> : <img src='../foto_relawan/$r[photo]'></td></tr> <tr><td class='left'>Ganti Gbr</td><td class='left'> : <input type=file name='fupload' size=30> *)</td></tr> <tr><td class='left' colspan=2>*) Apabila gambar tidak diubah, dikosongkan saja.</td></tr> <tr><td class='left' colspan=2><input type=submit value=Update> <input type=button value=Batal onclick=self.history.back()></td></tr> </tbody></table></form>"; break; } } ?>

109

You might also like