Membuat buku tamu

Buku tamu ini terdiri dari 2 file, file pertama bernama guestbook.php3 yang merupakan file utama. File kedua bernama entry.dat yang digunakan untuk menyimpan isi buku tamu.

<html>
<head>
<TITLE>Contoh Guestbook www.klik-kanan.com</TITLE>
<STYLE>
FONT,body,td,table {font-family : verdana;font-size : 11px;}
b {
font-family : Arial;
font-weight : bold;
}
a,a:hover,.link{font-family: verdana;font-size: 8pt;font-color: 66666;}
</STYLE>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="30" marginwidth="0" marginheight="0">
<b><center> BUKU TAMU <br></b>
dari www.klik-kanan.com</center>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td height="50"></td> </tr>
<tr>
<td><form action="<?PHP_SELF?>" method="post">
<table width="498" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td>Nama</td> <td> <input name="name" size=30 value=""> </td> </tr>
<tr> <td>Email</td> <td> <input name="email" size=30 value=""> </td> </tr>
<tr> <td>Homepage</td> <td> <input name="url" size=30 value="http://"> </td> </tr>
<tr> <td valign="top">Komentar</td> <td> <textarea name="message" cols=50 rows=10 wrap=soft></textarea> </td> </tr>
<tr> <td valign="top"> <input type="hidden" value="ok" name="send_status"> </td>
<td>
<input type="submit" value="Kirim" name="submit">
<input type="submit" value="Lihat" name="view_guestbook">
</td>
</tr>
</table></form>
</td>
</tr>
<tr>
<td> <center>

<?
if ($name == "" || $email == "" || $message == "")
{
for ($i=0; $i<3; $i++)
{
echo ".";
sleep(1);
flush();
}
$filesize = filesize("entry.dat");
$file = fopen("entry.dat","r");
$buffer = fread($file,$filesize);
echo "$buffer";
fclose($file);
}
else if ($send_status == "ok")
{
$filesize = filesize("entry.dat");
$file = fopen("entry.dat","r");
$buffer = fread($file,$filesize);
fclose($file);

$today = getdate();
$bulan = $today[month];
$mday = $today[mday];
$tahun = $today[year];
$tanggal = "$bulan $mday, $tahun";

$file = fopen("entry.dat","w");
$parsed_message = strip_tags($message,"<a>,<i>");
$parsed_message_br = str_replace("\n","<br>",$parsed_message);
$today = date( "Ymd", time() );
$message_table ="<TABLE BORDER=\"0\" CELLPADDING=\"1\" bgcolor=EEEEEE width=\"500\"><TD colspan=\"2\"></TD></TR> <TR><TD align=\"right\" colspan=\"2\"><i>$tanggal</i></TD></TR> <TR><TR><TD width=\"30%\"><B>Nama :</B></TD> <TD>$name</TD></TR> <TR><TD><B>Email :</B></TD> <TD><A HREF=\"mailto:$email\">$email</A></TD></TR> <TR><TD><B>Homepage :</B></TD> <TD><A HREF=\"$url\" target=\"_blank\">$url</A></TD></TR> <TR><TD valign=\"top\" colspan=\"1\"><B>Komentar :</B></TD><TD>$parsed_message_br</TD></TR> <TR><TD colspan=\"2\"></TD></TR></TABLE>";

fputs($file,"$message_table \n $buffer");
fclose($file);
}
else if ($view_guestbook == "View Guestbook"){

$filesize = filesize("entry.dat");
$file = fopen("entry.dat","r");
$buffer = fread($file,$filesize);
echo "$buffer";
fclose($file);

}
?></center>
</td>
</tr>
</tr>


</table>
<p>&nbsp;</p>
</body>
</html>


Download

1 comments:

Keep on writing, great job!
Visit my web site :: click This


EmoticonEmoticon