#native_company# #native_desc#
#native_cta#

SimpleBook

By cjpbob
on July 26, 2002

Version: 1

Type: Full Script

Category: BBS/Discussion

License: GNU General Public License

Description: A guestbook script that requires no database or even anything other than PHP. Uses “guestbook.txt” for entry storage, and formats text when writing it to the file. All you need is “Guestbook.php” and an empty text file with full permissions named “guestbook.txt” in the same directory. Once you have that, you’re set.
Working example at http://delta.glypto.com/~cjpbob/guestbook.php

<html>
<head>
<title>Guestbook</title>
</head>
<body bgcolor="#000000">
<font color="#888888">
<BODY LINK="#aaaaaa">    
<BODY VLINK="#aaaaaa">  
<body alink="#666666">
<?
if ($_POST["post"])
{
 	 if ($_POST["name"]=="")
	 {
	 }else{
$file=fopen("guestbook.txt", "a+");
$today = date("F j, Y, A");
$entry="Posted on:  ";
$entry.=$today;
$entry.="n";
$entry.="Name:  ";
$entry.=$_POST["name"];
$entry.="n";
$entry.="Email:  ";
$entry.="<a href='mailto:";
$entry.=$_POST["email"];
$entry.="'>";
$entry.=$_POST["email"];
$entry.="</a>";
$entry.="n";
if ($_POST["homepage"]=="http://www."){$_POST["homepage"]="";}
$entry.="Homepage:  ";
$entry.="<a href='";
$entry.=$_POST["homepage"];
$entry.="'>";
$entry.=$_POST["homepage"];
$entry.="</a>";
$entry.="n";
$entry.="Comments:  ";
$entry.=$_POST["comments"];
$entry.="n";
$entry.="n";
$entry.="n";
$entry=stripslashes($entry);
fwrite($file,$entry);
fclose($file);
}
}
if ($_POST["post"])
{
if ($_POST["name"]=="")
	 {
	 echo "At least give your name";
	 }}else{
$file=fopen("guestbook.txt", "r");
$size=filesize("guestbook.txt");
$contents=fread($file, $size);
$contents=nl2br($contents);
fclose($file);
}
?>
<form action="guestbook.php" method="POST">
Name::<input type="text" name="name"><br>
Email::<input type="text" name="email"><br>
Homepage::<input type="text" name="homepage" value="http://www."><br>
Comments::<Textarea cols=50 rows=5 name="comments">I am a loser</textarea><br>
<input type="submit" name="post" value="Sign">
<a href="index.php">Back to main</a>
<a href="guestbook.php">View book</a><br><br>
<?$file=fopen("guestbook.txt", "r");
$size=filesize("guestbook.txt");
$contents=fread($file, $size);
$contents=nl2br($contents);
echo "Guestbook is currently $size bytes";?><br><br>
<?echo $contents;?>