| Webmaster-Showcase.net | Guest Book | ||
What is a guestbook?In case your new to the web, a guestbook on the web is a place where visitors can leave their name and other bits of information for others to see. A web site that has a guestbook usually has two links - one takes you to a form where you can sign your name and maybe leave a comment, the other shows you all or part of the current guestbook entries.A Simple GuestbookHere is a super-simple guestbook.Sign my simple guestbook View my simple guestbook Use the "Show me how" button on those pages to view thr PHP code. Improving the Simple GuestbookThe simple guestbook works but has some flaws which will show up over time.
Valitity checksThe "gbook.php" script doesn't check either the $name or $comments values. It doesn't check if they were present or empty. What's wrong with that? (you ask) If the $name entry is missing or empty you end up with guestbook entries that are blank -- not a very good looking guestbook. Note that this simple guestbook is ensuring that no < characters are put into the geustbook file without being encoded. This prevents someone from maliciously writing PHP code in their comment that could, for example, delete all of your files! We took care of the programming danger but there is also potential social danger in a guestbook. Someone may write something that is offensive or slanderous and the entry is effectively anonymous - there it no way to know who did it. Because of the potential for abuse, the "simple-php-guestbook" data file is re-initialized every time this page is loaded. If you view the source of my real guestbook (use the "Guestbook" button in the site navagation column at the left of the screen then use the "Show me how" button to view its source) you will see that it checks for the presence of the $name value and it also encodes any "<" characters. Size provisionsWhen thousands of people have signed your guestbook, it may take a very long time for its contents to be viewed. The viewing procedure should only show a limited number of entries and then provide a means to scroll or page through the entries. | |||
| Home |
Show Me How | Feedback |
||
| Last updated: Fri Nov 8 22:38:43 2002 | ||||