WWW FAQs: How do I make a guestbook for my website?

2006-06-30: It's easy to make a guestbook, thanks to websites that provide free guestbook services. And I'll point those out to you, so if your skills are at a basic level, relax. I've got you covered! More advanced users who want a guestbook that operates entirely on their own website can read on to learn more.

"Hosted" Guestbooks

Are you willing to use a guestbook service hosted on another website? If you are, then setting up your guestbook is very simple.

www.a-free-guestbook.com offers a remarkably high-quality, free guestbook service. You can get a free guestbook just by signing up on their site. Surprisingly, their guestbook service currently has no advertising, even though the service is free.

While it's not certain that their site will always be 100% free of charge and free of advertising, it's definitely an attractive option right now... if you don't mind linking to your guestbook on another site, instead of making it part of your own.

There are also guestbook services that cost money. But if you're going to spend money, it makes more sense to upgrade your web hosting account to one that allows PHP, and run your own guestbook that you fully control.

Building Your Own Guestbook

Some users will prefer a guestbook that is part of their own website. And there are many guestbook scripts available on the Web. Quite a few of these are free, at least for noncommercial use. Your web hosting account does have to allow PHP, Perl/CGI or ASP before you can use these. Most free web hosting services do not allow any of these— sooner or later you get what you pay for. But your free web hosting company may also offer a built-in guestbook feature, so be sure to check their documentation.
"What is the HTML code for a guestbook?"

HTML determines what your web page will look like. But it can't make your web page actually do anything. Such as permanently saving a guestbook entry, for instance.

This is the reason why tools like PHP and ASP exist: to take things one step beyond HTML and let you actually do things with your HTML forms.

So HTML all by itself can't make a guestbook. But together with PHP, or another programming language on the web server, HTML can be part of a guestbook.

Does that mean it's scary and hard to make a guestbook? Not at all! PHP is designed to easily "added in" to your HTML. It's not that difficult and if you're interested in doing this yourself I'll show you how.

"If HTML can't do it alone, what about JavaScript?"

JavaScript makes things happen in the user's web browser. But you want to store guestbook entries on the web server, where other people can see them. So JavaScript is not the right tool for the job. Again, this is why PHP and ASP were invented. So we should use them for guestbooks and at any other time when we want to make things "really happen" on the web server.

Good Guestbook Programs To Try

The Ardguest Free PHP Guestbook Script is a simple, free guestbook for those with web hosting that includes PHP. Also see the guestbook section of the PHP Resource Index.

Those who have Windows-based hosting that supports ASP.NET but not PHP might try Uwe Kleim's ASP.NET Guestbook Application. Old-school ASP programmers will want to check out his original ASP Guestbook Application.

Or Try Mine: A Simple Guestbook In PHP

For those who want to know how it all works but need a little help getting started, here is a very simple PHP guestbook page. This will work just fine for you, as long as your host supports PHP. And if you are paying for your web hosting— it probably does support PHP just fine!

Feel free to use my simple guestbook code as a starting point for your own work.

I recently enhanced this guestbook to support deleting entries conveniently. That made the code a bit long to show on this page, so just use the download link provided in step one. You will get the complete code when you click on the link.
Just follow these steps to use my simple guestbook code:

1. Download guestbook.php (packaged in a zip file). Then upload it to your web server space.

2. Required: Change the $adminPassword setting at the top. You'll use this password when you log in to delete unwanted entries. And you will get unwanted entries - people often spam guestbooks.

3. Optional: Set the $guestbook variable to a file path on your web server that is not served up on the web. The default setting will probably work for everyone, but placing the file in the current directory means that users can probably download the raw guestbook file. Is that bad? In this case, not really. But more complex PHP programs might save private user information that not everyone should see.

This is a file path, NOT a URL; for example, /home/myaccountname/guestbook.dat is often correct. If you're not sure, just use the default setting. It's safe enough for a guestbook.

How It Works

For a detailed discussion of how my guestbook code works, see my article how can I receive form submissions? That article goes into plenty of detail about how to handle form submissions with PHP code.
There's one important catch with PHP scripts you download from other websites without understanding the code yourself: you need to keep an eye on the program's website and install any upgrades that are released to fix security flaws. Please take this seriously— do not allow your website to be wiped out by a malicious web "worm" that takes advantage of security holes in older versions of guestbook software.

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!