Home arrow PHP arrow Page 3 - Building A Quick-And-Dirty Guestbook With patGuestbook (part 1)

Home Sweet Home - PHP

Want to plug into what your site visitors actually think? All you need is a little time, a dollop of imagination and a copy of patGuestbook. More, inside.

  1. Building A Quick-And-Dirty Guestbook With patGuestbook (part 1)
  2. Introductions
  3. Home Sweet Home
  4. The Voice Of The People
  5. Playing The Field
  6. Code Poet
  7. User, User, On The Wall...
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 49
February 28, 2003

print this article


Since it's a PHP script, patGuestbook needs to live somewhere under your PHP-aware Web server's document root - typically, somewhere in the directory structure holding the rest of your Web site. For purposes of this tutorial, I shall assume that the application is located in the "patGuestbook" directory under the Web server root, and is accessible at the URL http://localhost/patGuestbook/

When you uncompress the source archive, you should see a directory structure that looks something like this:

patGuestbook | | | --- admin | --- config | --- skins | --- include | --- sql
Once you've got the files in an appropriate location, you also need to create some database tables to store patGuestbook data (if you're already using a database for your site, simply add patGuestbook's tables to that database). Look in the source archive's "sql" directory, where you'll find an SQL script to create two tables - "patgbguestbooks", which holds the master list of all the active guestbooks, and "patgbentries", which stores the actual guestbook entries.

Here's a quick glance at the SQL commands to create these tables:

DROP TABLE IF EXISTS patGbEntries; CREATE TABLE patGbEntries ( id int(10) unsigned NOT NULL auto_increment, guestbook int(10) unsigned NOT NULL default '0', date datetime NOT NULL default '0000-00-00 00:00:00', name varchar(100) default NULL, email varchar(200) default NULL, homepage varchar(200) default NULL, entry text NOT NULL, comment text, ratings text, flags set('approved') default NULL, PRIMARY KEY (id), KEY guestbook (guestbook), KEY flags (flags) ) TYPE=MyISAM; # -------------------------------------------------------- DROP TABLE IF EXISTS patGbGuestbooks; CREATE TABLE patGbGuestbooks ( id int(10) unsigned NOT NULL auto_increment, name varchar(20) NOT NULL default '', template varchar(255) NOT NULL default '', owner varchar(255) default NULL, entriespp tinyint(3) unsigned NOT NULL default '0', flags set('moderated','disabled','notify') NOT NULL default '', fieldconf text, PRIMARY KEY (id), UNIQUE KEY name (name) ) TYPE=MyISAM;
Next up, configuration. patGuestbook configuration is handled via a single file named "patGuestbook.php", located in the source distribution's "config" directory. It's fairly self-explanatory, take a look:

<?PHP /** * patGuestbook Config */ // Database configuration $db_host = "localhost"; $db_name = "patGuestbook"; $db_user = "me"; $db_pass = "secret"; // Directory where the templates for subscription pages are stored $skins_dir = "skins"; // Directory where the templates for the administration are stored $admin_template_dir = "templates"; ?>
Most of this is pretty standard information - patGuestbook needs to know the database access parameters so that it can get to its tables, and the location of the directories containing screen templates for the guestbook administration module and the guestbook itself (these templates are used by the patTemplate engine to render each page of the application, and can be customized to your needs - more on this later).

If you're using the default installation, you shouldn't need to change any of the information in this file, except the database access parameters. If, on the other hand, you're not using the default installation paths and are plan to integrate patGuestbook into your existing site structure, you should also alter the directory locations in the configuration file to reflect where the templates are located.

You can now check to see if patGuestbook is up and running, by visiting the URL (remember to alter this as per the installation path on your system): http://localhost/patGuestbook/example.php

patGuestbook should load up and display the following error message:

Could not identify guest book!
No need to panic - this is just an indication that the application could not find any guestbook in the system. This is probably because you have not yet created one - but hey, at least it confirms that you've got my configuration right.

Next, how about wiping out that error message by actually creating a guestbook?

>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: