Administration
  Home arrow Administration arrow Page 8 - Talk To Me!
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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? 
ADMINISTRATION

Talk To Me!
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 1
    2001-03-12

    Table of Contents:
  • Talk To Me!
  • The Job
  • Building The Foundation
  • Mole In A Hole
  • Speak Now, Or Forever Hold Your Peace
  • Of Trees And Branches
  • Closing The Loop
  • The Last Word

  • 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    Talk To Me! - The Last Word
    (Page 8 of 8 )

    There are a couple of other things that can be added to complete this application. First, since all this work will come to naught if the article and section numbers are not transmitted correctly, you can build in a rudimentary error check by validating the presence of these two variables before performing any database operation. In case these variables are not present, simply redirect the user to an error page.

    <? // redirect if missing important parameters // place at the top of every page if (!$article || !$section) { header("Location: error.php"); } ?>

    In the interests of consistency, you might also like to connect related posts to one another by including the string "Re: " in the subject line of replies, as on USENET. This is a relatively simple operation to accomplish - simply add this refinement to "post.php".

    <form action="<? echo $PHP_SELF; ?>" method="post"> <input type="hidden" name="replytopost" value="<?php echo $replytopost; ?>"> <input type="hidden" name="section" value="<?php echo $section; ?>"> <input type="hidden" name="article" value="<?php echo $article; ?>"> <table border="0" cellspacing="5" cellpadding="0"> <tr> <td colspan=2> <font face="Verdana, Arial" size="2" color="Black"><b>Your comment:</b></font><p> </td> </tr> <tr> <td><font face="Verdana, Arial" size="2" color="Black">Name</font></td> <td><input type="text" name="username" size="25"></td> </tr> <tr> <td><font face="Verdana, Arial" size="2" color="Black">Email address</font></td> <td><input type="text" name="email" size="25"></td> </tr> <? // if this is a reply to an existing post if ($replytopost) { // connect to database and pre-fill the subject field include("config.php"); $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); $query = "SELECT subject FROM $table WHERE id='$replytopost'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query . " . mysql_error()); list($subject) = mysql_fetch_row($result); // fix the subject line if necessary $substring = substr($subject,0, 3); if ($substring != "Re:") { $subject = "Re: " . $subject; } } ?> <tr> <td><font face="Verdana, Arial" size="2" color="Black">Subject</font></td> <td><input type="text" name="subject" size="25" value="<? if ($subject) { echo $subject; } ?>"></td> </tr> <tr> <td><font face="Verdana, Arial" size="2" color="Black">Comment</font></td> <td><textarea name="post" rows="5"></textarea></td> </tr> <tr> <td colspan=2 align=center><input type="submit" name="submit" value="Add Comment"></td> </tr> </table> </form>

    In the case of replies (indicated by the presence of the $replytopost variable), the subject field in the form is pre-filled with the subject of the parent post (obtained by querying the database), and the string "Re: " is prefixed to it. The user can, of course, replace this suggested subject line with anything else (s)he chooses.

    Here's what it looks like:



    Finally, it should be said that this system, as described above, is by no means perfect. For example, the passing of parameters via the URL GET method is an inherent vulnerability, allowing experienced users to alter the parameters and the subsequent attributes of the record in the database. A possible solution to this is to store the relevant numbers in session variables, which are inaccessible to the user, and thereby prevent mischief.

    It should also be noted that the architecture on which this application is premised is by no means optimal - a few obvious flaws present themselves, the primary one being the odd duality of the article and section number combination. However, when performing development on an existing, active Web site with a pre-defined database architecture (as we were), and given the constraints inherent in such a situation, it's difficult to redesign a system from scratch, and often, the only practical (and cost-effective) option is to simply build on existing plumbing rather than going back to square one.

    Either way, I hope this case study has given you some insight into how many Web sites build their online discussion forums, and perhaps also sparked some ideas on how you can apply this application to your own development activities. See you soon!

    This article copyright Melonfire 2001. All rights reserved.
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    ADMINISTRATION ARTICLES

    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems
    - More Hacks for the User Environment in BSD
    - Personalizing the User Environment in BSD
    - Customizing the User Environment in BSD

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway