<html>
<head>
<title>Buku Tamu</title>
</head>
<body>
<form name="form_bukutamu" method="post" action="proses_bukutamu.php">
<table width="40" border="0">
<tr>
<td>Nama</td>
<tr>
<td><input type="text" name="nama"></td>
</tr>
</tr>
<tr>
<td>Pesan</td>
</tr>
<tr>
<td><textarea name="komentar" rows="3"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="OK">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
include "koneksi.php";
$nama = $_POST['nama'];
$komentar = $_POST['komentar'];
$tanggal = date("Y-m-d");
$query = "INSERT INTO bukutamu (id,nama,komentar,tanggal) VALUES ('','$nama','$komentar','$tanggal')";
mysql_query($query)or die ("input data gagal".mysql_error());
echo "Query Berhasil <br>";
echo "<a href=tampil.php> Lihat Buku Tamu</a>";
?>
<?php
include "koneksi.php";
$query = "SELECT * FROM bukutamu ORDER BY id DESC";
$result = mysql_query($query);
while ($row=mysql_fetch_array($result))
{
echo "<b>Nama :</b> $row[nama] <br>
<b>Tanggal :</b> $row[tanggal]<br>
<b>Komentar :</b> $row[komentar]<br><br><br>";
}
?>
<html>
<head>
<title>Buku Tamu</title>
</head>
<body>
<?php
if(isset($_GET['tampil'])){
include "koneksi.php";
$query = "SELECT * FROM bukutamu ";
$result = mysql_query($query);
while ($row=mysql_fetch_array($result))
{
echo "<b>Nama :</b> $row[nama] <br>
<b>Tanggal :</b> $row[tanggal]<br>
<b>Komentar :</b> $row[komentar]<br><br><br>";
}
}
?>
<form name="form_bukutamu" method="post" action="proses_bukutamu.php">
<table width="40" border="0">
<tr>
<td>Nama</td>
<tr>
<td><input type="text" name="nama"></td>
</tr>
</tr>
<tr>
<td>Pesan</td>
</tr>
<tr>
<td><textarea name="komentar" rows="3"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="OK">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
proses_bukutamu.php<?php
include "koneksi.php";
$nama = $_POST['nama'];
$komentar = $_POST['komentar'];
$tanggal = date("Y-m-d");
$query = "INSERT INTO bukutamu (id,nama,komentar,tanggal) VALUES ('','$nama','$komentar','$tanggal')";
mysql_query($query)or die ("input data gagal".mysql_error());
header("Location: bukutamu.php?tampil=1");
exit;
?>
<?php
if(isset($_GET['tampil'])){
include "koneksi.php";
$query = "SELECT * FROM bukutamu ";
$result = mysql_query($query);
while ($row=mysql_fetch_array($result))
{
echo "<b>Nama :</b> $row[nama] <br>
<b>Tanggal :</b> $row[tanggal]<br>
<b>Komentar :</b> $row[komentar]<br><br><br>";
}
}
?>
menjadi:<?php
include "koneksi.php";
$query = "SELECT * FROM bukutamu ";
$result = mysql_query($query);
while ($row=mysql_fetch_array($result))
{
echo "<b>Nama :</b> $row[nama] <br>
<b>Tanggal :</b> $row[tanggal]<br>
<b>Komentar :</b> $row[komentar]<br><br><br>";
}
?>