1. config.php <?php $server="localhost"; $user="root"; $pass="password"; $db="perpus"; $koneksi=mysql_connect($server,$user,$pass); mysql_select_db($db,$koneksi) or die("koneksi Gagal"); 2. input_anggota.php <html><head><title>form ANGGOTA</title></head> <form action="proses_anggota.php" method="post"> <table border=5> <tr><td colspan=2 align=center><b>form INPUT DATA ANGGOTA</b></td></tr> <tr><td>id ANGGOTA</td><td><input type="text" name="id"></td></tr> <tr><td>nama ANGGOTA</td><td><input type="text" name="nama"></td></tr> <tr><td>alamat</td><td><textarea name="alamat"></textarea></td></tr> <tr><td>jenis KELAMIN</td><td><input type="radio" name="jns" value="p">pria<input type="radio" name="jns" value="w">wanita</td></tr> <tr><td colspan=2 align=center><input type="submit" value="simpan"><input type="reset" value="batal"></td></tr> </table> </form>
3. proses_anggota.php <html><head><title>proses ANGGOTA</title></head> $id=$_post['id']; $nama=$_post['nama']; $alamat=$_post['alamat']; $kelamin=$_post['jns']; $simpan="insert into anggota values('$id','$nama','$alamat','$kelamin')"; mysql_query($simpan,$koneksi); <table border=0> <tr><td><b><u>silahkan PILIH</u></b><br></td></tr> <tr><td hight=20><form action="tampil_anggota.php" method="post"><input type="submit" value="lihat Data Anggota"></form></td></tr> <tr><td hight=20><form action="input_anggota.php" method="post"><input type="submit" value="input Data Anggota"></form></td></tr> </table> 4. hapus_anggota.php <html><head><title>tampil ANGGOTA</title></head> $id=$_get['id']; $hapus="delete from anggota where id='$id'"; mysql_query($hapus,$koneksi); include("tampil_anggota.php");
5. tampil_anggota.php <html><head><title>tampil ANGGOTA</title></head> $show="select*from anggota"; $tampil=mysql_query($show,$koneksi); <b><u>data ANGGOTA</u></b><br><br> <table border=1> <tr><th width=150>id ANGGOTA</th><th width=150>nama ANGGOTA</th><th width=150>alamat</th><th width=150>jenis KELAMIN</th><th>PILIHAN</th></tr> <? while($baris=mysql_fetch_array($tampil)) { <tr> <td width=150><? echo $baris[id]; </td> <td width=150><? echo $baris[nama]; </td> <td width=150><? echo $baris[alamat]; </td> <td width=150><? echo $baris[kelamin]; </td> <td width=150 align="center"><a href="hapus_anggota.php?id=<? echo $baris[id]; "><font color="red"><b>hapus</b></font></a> <a href="edit_anggota.php?id=<? echo $baris[id]; "><font color="blue" ><b>ubah</b></font></a></td> </tr> <? } </table><br> <form action="cari_anggota.php" method="post"><input type="text" name="cari"><input type="submit" Value="CARI"></form> <form action="input_anggota.php" method="post"><input type="submit" Value="Input Data Anggota"></form>
6. edit_anggota.php <html><head><title>edit ANGGOTA</title></head> $id=$_get['id']; $show="select * from anggota where id='$id'"; $tampil=mysql_query($show,$koneksi); $data=mysql_fetch_array($tampil); $nama="$data[nama]"; $alamat="$data[alamat]"; $kelamin="$data[kelamin]"; <form action="update_anggota.php" method="post"> <table border=5> <tr><td colspan=2 align=center>form INPUT DATA ANGGOTA</td></tr> <tr><td>id ANGGOTA</td><td><input type="text" name="id" value="<? echo $id; "></td></tr> <tr><td>nama ANGGOTA</td><td><input type="text" name="nama" value="<? echo $nama; "></td></tr> <tr><td>alamat</td><td><textarea name="alamat"><? echo $alamat; </textarea></td></tr> <tr><td>jenis KELAMIN</td><td> <? if($kelamin=='p'){ <input type="radio" name="jns" value="p" checked= checked >PRIA<input type="radio" name="jns" value="w">wanita <? } else { <input type="radio" name="jns" value="p">pria<input type="radio" name="jns" value="w" checked= checked >WANITA <? } </td></tr> <tr><td colspan=2 align=center><input type="submit" value="update"><input type="reset" value="batal"></td></tr> </table> </form>
7. update_anggota.php <html><head><title>update ANGGOTA</title></head> $id=$_post['id']; $nama=$_post['nama']; $alamat=$_post['alamat']; $kelamin=$_post['jns']; $update="update anggota set id='$id',nama='$nama',alamat='$alamat',kelamin='$kelamin'"; mysql_query($update,$koneksi); include("tampil_anggota.php"); 8. refresh.php <html><head><title>tampil ANGGOTA</title></head> include("tampil_anggota.php");
9. cari_anggota.php <html><head><title>cari ANGGOTA</title></head> $id=$_post['cari']; $show="select*from anggota where id='$id' or nama='$id' or alamat='$id' or kelamin='$id'"; $tampil=mysql_query($show,$koneksi); <b><u>data ANGGOTA</u></b><br><br> <table border=1> <tr><th width=150>id ANGGOTA</th><th width=150>nama ANGGOTA</th><th width=150>alamat</th><th width=150>jenis KELAMIN</th><th>PILIHAN</th></tr> <? while($baris=mysql_fetch_array($tampil)) { <tr> <td width=150><? echo $baris[id]; </td> <td width=150><? echo $baris[nama]; </td> <td width=150><? echo $baris[alamat]; </td> <td width=150><? echo $baris[kelamin]; </td> <td width=150 align="center"><a href="hapus_anggota.php?id=<? echo $baris[id]; "><font color="red"><b>hapus</b></font></a> <a href="edit_anggota.php?id=<? echo $baris[id]; "><font color="blue" underline=false><b>ubah</b></font></a></td> </tr> <? } </table><br> <table border=0> <tr><td><form action="cari_anggota.php" method="post"><input type="text" name="cari"><input type="submit" Value="CARI"></form></td><td><form action="refresh.php" method="post"><input type="submit" Value="REFRESH"></form></td></tr></table> <form action="input_anggota.php" method="post"><input type="submit" Value="Input Data Anggota"></form>