Você está na página 1de 3

Listing input Buku Tamu

<form id="form1" name="form1" method="post" action="simpanbukutamu.php"> <table


width="417"
height="219"
border="1">
<tr>
<td
colspan="3"><div
align="center"><h1><strong>Buku Tamu </strong></h1></div></td></tr> <tr> <td
width="99"
height="36">Nama</td><td
width="11">&nbsp;</td><td
width="285"><label>
<input
name="txtnm"
type="text"
id="txtnm"
/></label></td></tr> <tr><td height="37"> E-mail</td><td>&nbsp;</td> <td><input
name="txtemail"
type="text"
id="txtemail"
/></td></tr>
<tr>
<td
height="54">Pesan</td> <td>&nbsp;</td> <td><label><textarea name="txtpesan"
id="txtpesan"></textarea>
</label></td>
</tr>
<tr><td>&nbsp;</td><td>&nbsp;</td>
<td><label><input
type="submit"
name="Submit" value="Kirim" /><input type="reset" name="Submit2" value="Batal" />
<a href="tampilbukutamu.php">[Lihat Buku Tamu]</a>
</label></td></tr>
</table></form>
Listing Simpan Buku Tamu
<?php
mysql_connect('localhost','root','password') or die (mysql_error());
mysql_select_db('db_berita2') or die (mysql_error());
$nama=$_POST['txtnm']; $email=$_POST['txtemail']; $pesan=$_POST['txtpesan']; $perintah="insert
buku_tamu values('','$nama','$email','$pesan')"; $simpan=mysql_query($perintah) or die (mysql_error());

into

if ($simpan)
{ echo"<script> alert('Data telah tersimpan!'); document.location='Bukutamu.php'; </script>"; }
else
{ echo"Gagal Disimpan!"; } ?>
Tampil Buku Tamu
<table width="829" height="191" border="1"> <tr><td colspan="6" align="center" valign="middle"><div
align="center"><h1>DATA BUKU TAMU </h1> </div></td></tr> <tr><td width="34" align="center"
valign="middle"
bgcolor="#3366FF">ID</td>
<td
width="275"
align="center"
valign="middle"
bgcolor="#3366FF">Nama</td> <td width="183" align="center" valign="middle" bgcolor="#3366FF">Email</td> <td width="183" align="center" valign="middle" bgcolor="#3366FF">Pesan</td> <td colspan="2"
align="center" valign="middle" bgcolor="#3366FF">Action</td></tr>
<?php
mysql_connect("localhost","root","password") or die (mysql_error());
mysql_select_db("db_berita2") or die (mysql_error());
$perintah="select * from buku_tamu"; $tampil=mysql_query($perintah) or die (mysql_error());
$jumlah=mysql_num_rows($tampil); while($isi=mysql_fetch_array($tampil))

{ ?>
<tr> <td height="47"><?php echo $isi['Id']; ?></td> <td><?php echo $isi['Nama']; ?></td> <td><?php echo
$isi['Email']; ?></td> <td><?php echo $isi['Pesan'];?></td> <td width="67" align="center" valign="middle"><a
href="hapusbukutamu.php?id=<?php echo $isi['Id']; ?>">HAPUS</a></td><td width="47" align="center"
valign="middle"><a href="editbukutamu.php?id=<?php echo $isi['Id']; ?>">EDIT</a></td> </tr>
<?php } ?> <tr><td colspan="6"><strong>Jumlah Record: <?php echo $jumlah; ?></strong> </td></tr> </table>
Edit Buku Tamu
<?php
mysql_connect("localhost","root","password") or die (mysql_error());
mysql_select_db("db_berita2") or die (mysql_error());
$id=$_GET['id']; $sql="select * from buku_tamu where id='$id'"; $tampil=mysql_query($sql) or die
(mysql_error()); $isi=mysql_fetch_array($tampil); ?>
<form id="form1" name="form1" method="post" action="updatebukutamu.php">
<table width="606"
height="227" border="1"> <tr> <td colspan="2" bgcolor="#0033CC"><h1 align="center">Edit Buku Tamu
</h1></td> </tr> <tr><td width="54">Id</td><td width="285"><?php echo $isi['Id'];?><input name="idh"
type="hidden" id="idh" value="<?php echo $isi['Id'];?>" /></td></tr>
<tr><td>Nama</td><td><input
name="nama" type="text" id="nama" value="<?php echo $isi['Nama'];?>" /></td></tr> <tr> <td>Email</td>
<td><label><input name="email" type="text" id="email" value="<?php echo $isi['Email'];?>" /></label></td></tr>
<tr><td height="68">Pesan</td><td><label><textarea name="pesan" cols="30" rows="5" id="pesan"><?php echo
$isi['Pesan'];?></textarea></label></td></tr>
<tr><td
height="28"
colspan="2"><label></label><div
align="center"> <label><input type="submit" name="Submit" value="Update" /> </label><label><input
type="reset" name="Submit2" value="Batal" /></label></div></td> </tr> </table> </form>
Update Buku Tamu
<?php
mysql_connect("localhost","root","password") or die (mysql_error());
mysql_select_db("db_berita2") or die (mysql_error());
$id=$_POST['idh']; $nama=$_POST['nama']; $email=$_POST['email'];
$pesan=$_POST['pesan']; $sql="update buku_tamu set Nama='$nama', Email='$email', Pesan='$pesan' where
Id='$id'"; $edit=mysql_query($sql) or die (mysql_error());
If ($edit)
{

echo"<script> alert('Berhasil Diubah');

document.location='tampilbukutamu.php'; </script>"; }

else
{ echo "<script> alert('GAGAL diubah'); document.location='tampilbukutamu.php'; </script>"; } ?>

Hapus Buku Tamu


<?php
mysql_connect("localhost","root","password") or die (mysql_error());
mysql_select_db("db_berita2") or die (mysql_error());
$id=$_POST ['idh']; $nama=$_POST ['txtnama']; $email=$_POST ['txtemail']; $pesan=$_POST ['txtpesan'];
$id=$_GET['id']; $sql="delete from buku_tamu where Id='$id'"; $hapus=mysql_query($sql) or die (mysql_error());
If ($hapus)
{ echo"<script> alert('Berhasil Dihapus'); document.location='tampilbukutamu.php'; </script>"; }
else
{ echo "<script> alert('GAGAL dihapus'); document.location='tampilbukutamu.php'; </script>"; } ?>

Você também pode gostar