Script
input.php
<body>
<form action="simpan.php"
method="post" target="_self">
<table width="50%"
border="2" cellspacing="1" cellpadding="1">
<tr>
<td>id pegawai</td>
<td><input name="txtid" type="text"
id="txtid"></td>
</tr>
<tr>
<td>nama</td>
<td><input name="txtnp" type="text"
id="txtnp"></td>
</tr>
<tr>
<td>alamat</td>
<td><textarea name="txtal"
id="txtal"></textarea></td>
</tr>
<tr>
<td>gender</td>
<td><input name="jk" type="radio"
value="pria" checked>
pria
<input name="jk" type="radio"
value="wanita">
wanita</td>
</tr>
<tr>
<td><input type="submit" name="Submit"
value="simpan"></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Script
simpan.php
<body>
<?php
$koneksi=mysql_connect("localhost","root","password");
mysql_select_db("db_anggota",$koneksi);
$id=$_POST['txtid'];
$np=$_POST['txtnp'];
$al=$_POST['txtal'];
$jk=$_POST['jk'];
$sql="insert into
anggota(id,nama,alamat,gender)values('$id','$np','$al','$jk')";
mysql_query($sql,$koneksi);
echo "data berhasil di simpan";
?>
<br>
<a href="tampil_edithapus.php">HAPUS DATA</a>
</body>
</html>
Script
tampil_edithapus.php
<body
background="file:///C|/apache2triad/htdocs/RKT/Water lilies.jpg"
<table width="50%"
border="2" cellspacing="2" cellpadding="2">
<tr>
<td colspan="6"><div
align="center"><strong>Tampil Data
Anggota</strong></div></td>
</tr>
<tr bgcolor="#00FF00">
<td><strong>ID</strong></td>
<td><strong>NAMA</strong></td>
<td><strong>ALAMAT</strong></td>
<td><strong>GENDER</strong></td>
<td colspan="2"><div
align="center"><strong>TOMBOL</strong></div></td>
</tr>
<?php
$koneksi=mysql_connect("localhost","root","password");
if($koneksi)
{
mysql_select_db("db_anggota",$koneksi);
$sql=mysql_query("select* from anggota",$koneksi);
while($data=mysql_fetch_array($sql))
{
?>
<tr>
<td><?php echo
$data['id'];?> </td>
<td><?php echo
$data['nama'];?> </td>
<td><?php echo
$data['alamat'];?> </td>
<td><?php echo $data['gender'];?>
</td>
<td align="center"> <a href="hapusdata.php?ID=<?php echo
$data['id'];?>">HAPUS</a></td>
<td align="center"><a
href="ubahdata.php?ID=<?php echo $data['id'];?>">UBAH</a></td>
</tr>
<?php
}} ?>
</table>
</body>
</html>
Script
hapusdata.php
<body>
<?php
$koneksi=mysql_connect("localhost","root","password");
mysql_select_db("db_anggota",$koneksi);
$ID=$_GET['ID'];
$sql="DELETE FROM anggota where
id='$ID'";
$qry=mysql_query($sql,$koneksi);
if($qry)
{
include"tampilhapus.php";
echo"<font size=+2>data anggota
dengan Id = $ID berhasil dihapus</font><br>";
}
else
echo"gagal menghapus";
exit;
?>
</body>
</html>
Script
ubahdata.php
<body>
<?php
$koneksi=mysql_connect("localhost","root","password");
mysql_select_db("db_anggota",$koneksi);
$ID=$_GET['ID'];
$sql="select * from anggota where
id='$ID'";
$query=mysql_query($sql,$koneksi);
$data=mysql_fetch_array($query);
$ID=$data['id'];
$nama=$data['nama'];
$alamat=$data['alamat'];
if($data['gender']=="PRIA"){
$cekp="checked";
$cekw="";}
else{
$cekp="";
$cekw="checked";}
?>
<form action="ubahsimpan.php" method="POST" target="_self">
<table width="30%" border="2" cellspacing="2"
cellpadding="2">
<tr>
<td colspan="2"><strong>UBAH DATA
PESAWAT</strong></td>
</tr>
<tr>
<td width="36%">ID</td>
<td width="64%">
<input type="text"
id="txtid" size="10" name="txtid"
value="<?php echo "$ID"; ?>" maxlength="20"
disabled/>
<input name="ID"
type="hidden" value="<?php
echo"$ID";?>"/>
</td>
</tr>
<tr>
<td height="30">Nama</td>
<td><input type="text" name="txtnama"
value="<?php echo"$nama"; ?>"
maxlength="35"/>
</td>
</tr>
<tr>
<td>Alamat</td>
<td>
<input type="text" name="txtalamat"
value="<?php echo"$alamat"; ?>"
maxlength="35"/>
</td>
</tr>
<tr>
<td>Gender</td>
<td>
<input name="gender" type="radio"
value="PRIA" checked <?php echo"$cekp"; ?> />
PRIA
<input name="gender" type="radio"
value="WANITA" <?php echo"$cekw"; ?> />
WANITA</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit"
value="SIMPAN"></td>
</tr>
</table>
</form>
</body>
</html>
Script
ubahsimpan.php
<body>
<?php
$koneksi=mysql_connect("localhost","root","password");
if($koneksi)
{
mysql_select_db("db_anggota",$koneksi);
$IDH=$_POST['ID'];
$b=$_POST['txtnama'];
$c=$_POST['txtalamat'];
$d=$_POST['gender'];
$sql="update anggota set
nama='$b',alamat='$c',gender='$d' where id ='$ID' ";
mysql_query($sql,$koneksi);
echo"Data Berhasil Diubah";
include"tampilubah.php";
}
?>
</body>
</html>
Created by Biro Teknologi Informasi
No comments:
Post a Comment