Hudzilla.org - the homepage of Paul Hudson
Contents > Practical PHP > Creating a guestbook Wish List | Report Bug | About Me ]

22.2.5     Building a better guestbook

This is NOT the latest copy of this book; click here for the latest version.

What we've built so far is a fairly simple, yet workable guestbook. Although you can post and read messages and also have bad words/HTML content stripped out, it still leaves a lot to be desired. If you are interested in expanding your guestbook, consider these ideas:

  • Enable moderation of posts, where all posts need to be vetted by a moderator then approved. The easiest way to do this would be to have a field, IsVisible, set to 0 (invisible) for all new posts, then have it set to 1 (visible) when approved - you can simply filter for IsVisible = 1 in read.php

  • Make it have multiple pages if the guestbook gets too long, e.g. "Messages 1-100", "Messages 101-200", "Messages 201 to 299", etc. The easy way to achieve this is to use the LIMIT clause in your SELECT query for read.php and store a variable like $start. For example: SELECT foo FROM bar ORDER BY DateSubmitted DESC LIMIT $start, 100;

  • Have a preview message option that will show how the poster's entry would look if added to the database.

  • Allow visitors to edit or delete their post. This might sound tricky, but really all you need to do is ask people to enter a password as part of the entry submission form - if they select to edit or delete an entry, they need to provide the matching password to proceed.

Guestbooks are so often frowned upon by web veterans as being for newbies only, which is rubbish - there is so much you can do with a simple guestbook that it is a great place to sharpen your skills.





<< 22.2.4 Fixing the problems   22.3 Creating a messageboard >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is five plus four?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow