MySQL
  Home arrow MySQL arrow Page 4 - Building a Simple ColdFusion Content M...
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
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? 
MYSQL

Building a Simple ColdFusion Content Management System with MySQL
By: Charles Kaufmann
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 45
    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:
      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

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    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


       · Very good explanation on building table in mySQL, I could do with more help building...
       · The code is very unclear. The author jumps from one page to another without any...
       · I disagree with the previous poster. Yes, you must be familiar with cfoldfusion to...
     

       

    MYSQL ARTICLES

    - 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...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...





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