PHP
  Home arrow PHP arrow Page 3 - Building A Quick-And-Dirty Guestbook W...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building A Quick-And-Dirty Guestbook With patGuestbook (part 1)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 43
    2003-02-28

    Table of Contents:
  • Building A Quick-And-Dirty Guestbook With patGuestbook (part 1)
  • Introductions
  • Home Sweet Home
  • The Voice Of The People
  • Playing The Field
  • Code Poet
  • User, User, On The Wall...

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building A Quick-And-Dirty Guestbook With patGuestbook (part 1) - Home Sweet Home


    (Page 3 of 7 )

    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


       · As I am the first one to comment on this. It is a nice topic I enjoyed it while...
     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT