PHP
  Home arrow PHP arrow Page 6 - Building A Quick-And-Dirty Guestbook With patGuestbook (part 1)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PHP

Building A Quick-And-Dirty Guestbook With patGuestbook (part 1)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 49
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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) - Code Poet
    ( Page 6 of 7 )

    Now that the guestbook has been configured, all that's left is to integrate it into your Web site. And even that's a pretty simple task to accomplish - pop open the included sample PHP script, "example.php", which lives in your source distribution's root directory, and take a quick peek at what's inside it (I've added comments to the code so that it's easier to see what's happening):


    <?php // include required classes require_once( "config/patGuestbook.php" ); require_once( "include/patGuestbook.php" ); require_once( "include/patTemplate.php" ); require_once( "include/patDbc.php" ); // initialize template engine $template = new patTemplate; // set base directory to look for templates $template->setBasedir( $skins_dir ); // initialize DB abstraction layer $dbc = new patMySqlDbc( $db_host, $db_name, $db_user, $db_pass ); // initialize guestbook $guestbook = new patGuestbook; // connect guestbook to template engine and DB connection $guestbook->setTemplate( $template ); $guestbook->setDbc( $dbc ); // set skin to use for guestbook if( !empty( $skin ) ) $guestbook->setSkin( $skin ); // display guestbook $guestbook->process( array( "name" => "Voice Of The People" ) ); ?>
    Nothing too complicated here. First, the script include()-s the files that contain the API functions required by patGuestbook.

    // include required classes require_once( "config/patGuestbook.php" ); require_once( "include/patGuestbook.php" ); require_once( "include/patTemplate.php" ); require_once( "include/patDbc.php" );
    This is followed by initialization and creation of the patGuestbook object, which serves as the focal point for all future guestbook operations, together with the template engine and database connection point.

    // initialize template engine $template = new patTemplate; // initialize DB abstraction layer $dbc = new patMySqlDbc( $db_host, $db_name, $db_user, $db_pass ); // initialize guestbook $guestbook = new patGuestbook; // connect guestbook to template engine and DB connection $guestbook->setTemplate( $template ); $guestbook->setDbc( $dbc );
    Once that's done, the patGuestbook object's process() method can be used to select and display the guestbook.

    // display guestbook $guestbook->process( array( "name" => "Voice Of The People" ) );
    You can use the bare-bones skeleton above to create your own PHP scripts, or even integrate the lines of code above into your existing site. Either way, this is all you need to do to get a guestbook up and running. Painless, isn't it?

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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek