I need a banner free guestbook with no links to other pages, just mine. So if anyone knows of a guestbook script let me know.. maybe i should ask PHP, but i need a guestbook... maybe a generator would be better.
WARNING: non-exposure to the Son can cause burning!
You will need a file named guestbook.txt CHMODed to 666 (read/writeable).
PHP Code:
<?PHP
$filename = "guestbook.txt"; #CHMOD to 666
$text = "";
if (isset($_POST["submit"])) {
$name = htmlspecialchars($_POST["name"]);
$message = htmlspecialchars($_POST["message"]);
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$value = $message."<br>\n<span style=\"font-family: verdana, arial, sans-serif; font-size: 70%; font-weight: bold;\">Posted by $name at $time on $date.</span>\n<break>\n";
##Write the file##
$fp = fopen ($filename, "a");
if ($fp) {
fwrite ($fp, $value);
fclose ($fp);
}
else {
echo ("Your entry could not be added.");
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Guestbook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
You don't type anything in guestbook.txt... just upload the blank file. To CHMOD, you will need to FTP to your site, and check the documentation on how to CHMOD files...
No, sorry. Let me explain what CHMOD is. CHMOD is the Unix/Linux way to change the permissions of a file. Basically, it is just a Unix command to tell the file to be able to be written to.
Anyway, the script should create the file if it does not exist, so try just running guestbook.php without even uploading guestbook.txt... It should create it for you.
This code you gave Pyro, I copied it into notepad...so can I just upload that notepad file into my host directory then as well as the blank guestbook.txt file?
Or do I need to paste the code you gave us onto a web page document then save it? I know this sounds painfully simple but I am unfamiliar with PHP.
Secondly if I do have to paste the code into a web page document..do I have to save it as a PHP or just save it as I would any other web page?
Thanks.
Humankind cannot gain anything without first giving something in return.
To obtain, something of equal value must be lost.
That is Alchemy's first law of Equivalent Exchange.
In those days we really believed that to be the worlds one, and only truth. - FullMetal Alchemist
Basically what you do is take all the code in the PHP block above and copy it into any HTML/plain text editor. Then, save the file with a .php extention (for PHP to be processed, it must have a .php extention). So yes, just copy the code into notepad, and save with a .php extention. Now, make a .txt file named guestbook.txt and upload that to the server as well. Once it is on the server, CHMOD the guestbook.txt file to 666 (so the PHP script can write to it).
Humankind cannot gain anything without first giving something in return.
To obtain, something of equal value must be lost.
That is Alchemy's first law of Equivalent Exchange.
In those days we really believed that to be the worlds one, and only truth. - FullMetal Alchemist
Okay..here is another inquery..I would like the newest entry to appear at the top..what do I need to alter in order to make this happen?
Please keep in mind I am a complete idiot when it comes to PHP so don't get too techy on me.
Humankind cannot gain anything without first giving something in return.
To obtain, something of equal value must be lost.
That is Alchemy's first law of Equivalent Exchange.
In those days we really believed that to be the worlds one, and only truth. - FullMetal Alchemist
Here is what I have so far..tell me if this looks correct please.
P.S..I altered the background color and text color..so that is why there is CSS.
PHP Code:
<?PHP
$filename = "guestbook.txt"; #CHMOD to 666
$text = "";
if (isset($_POST["submit"])) {
$name = $_POST["name"];
$message = $_POST["message"];
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$value = $message."<br>\n<span style=\"font-family: verdana, arial, sans-serif; font-size: 70%; font-weight: bold;\">Posted by $name at $time on $date.</span>\n<break>\n";
##Read old file##
Last edited by Dark Dragon; 10-14-2003 at 04:25 PM.
Humankind cannot gain anything without first giving something in return.
To obtain, something of equal value must be lost.
That is Alchemy's first law of Equivalent Exchange.
In those days we really believed that to be the worlds one, and only truth. - FullMetal Alchemist
Bookmarks