MySQL
  Home arrow MySQL arrow Page 4 - Building a Simple ColdFusion Content Management System with MySQL
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  
MYSQL

Building a Simple ColdFusion Content Management System with MySQL
By: Charles Kaufmann
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 46
    2004-08-11


    Table of Contents:
  • Building a Simple ColdFusion Content Management System with MySQL
  • Starting With MySQL
  • The Page and how to Update/Modify and Delete
  • Add/Modify Form
  • Action
  • Breadcrumb List
  • Side Menu
  • Site Map

  • 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 Simple ColdFusion Content Management System with MySQL - Add/Modify Form
    ( Page 4 of 8 )

    We are now going to look at the add and modify process of this application. When you click on either the Modify or Add link it will take you to the first part of the CFIF statement. I am just going to state once for the record that these forms were intentionally left very plain. I was going for function, you can make it look nice when you integrate it into your site.

    Here is the code:

    1  <cfif isdefined("url.mod")>
               <cfset url.id = #url.mod#>
       <cfelse>
               <cfset url.id = 0>
       </cfif>
    2  <cfquery name="getpage" datasource="#variables.data#">
    3     Select *
    4     From tblpages
    5     where id = #url.id# and status = 'A'
    6  </cfquery>
    7  <form action="page.cfm" method="post" name="form1">
    8  <cfoutput>
    9  Title:<br />
    10 <input type="Text" name="title" value="#getpage.title#" /><br />
    11
    12 Body:<br />
    13 <textarea name="body" cols="40" rows="10">#getpage.body#</textarea>
    14 <br />
    15
    16 <cfif isdefined("url.add")>
    17   <input type="Hidden" name="id" value="#url.add#" />
    18   <input type="Submit" name="Add" Value="Add" />
    19 <cfelse>
    20   <input type="Hidden" name="id" value="#url.mod#" />
    21   <input type="Submit" name="Modify" value="Modify" />
    22 </cfif>
    23 </cfoutput>
    24 </form>
     

    Now I will walk through the above code. The first CFIF statement (line 1) sets a url.id to either 0 for a new record, or a value that was passed in the "url.mod". What this does for you is if you are modifying a page, it will show the information in the form, if you are adding a page the form will be blank.

    The CFQUERY queries out the record if you are modifying. Set the form's ACTION to the same page you are working on. Lines 8 through 14 place the form fields on the page and populate them with values if you are modifying the record. Lines 16 through 23 test to see what you are trying to and sends you to the appropriate action. If you are trying to modify an existing document the submit button is named Modify with a value of Modify. If you are trying to add a new document then the submit button is named Add with a value of Add. That way you can put the appropriate action in the section of the page's CFIF statements. All you have to do is see if the form variables are ISDEFINED.



     
     
    >>> More MySQL Articles          >>> More By Charles Kaufmann
     

       

    MYSQL ARTICLES

    - MySQL Security Tips
    - Designing a MySQL Database: Tips and Techniq...
    - The Three Most Important MySQL Queries
    - Null and Empty Strings
    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...





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