Considerations

Team-Fly    

ColdFusion® MX: From Static to Dynamic in 10 Steps
By Barry Moore
Table of Contents
Step 6.  Updating, Inserting, and Deleting Database Records


Database information typically is quite important to the person who owns the database and should be protected. One of the great things about database programs is that they are very powerful. However, it is just that power that we as application developers need to be aware of and even a bit afraid of. It is easy to harness the power of a database to update or change thousands of records at a time. It is just as easy, however, to accidentally delete thousands of records in one fell swoop. Most database systems will happily do whatever you ask of them. If you accidentally delete a large chunk of data, there usually is no way for you to get it back unless there is a backup copy of the database somewhere.

Because databases are so powerful, most end users need to be protected from making mistakes that could prove costly. Therefore, beginning with this step, we are going to start building a bit of code into our applications that will help keep users from breaking our web site and doing bad things to good data.

One of the tags we will be using to accomplish this is the <CFLOCATION> tag. This tag is used to redirect the browser to a different URL. When ColdFusion Server comes across a <CFLOCATION> tag in a template, the server ceases processing any more code in that template and immediately redirects the user's browser to the page specified with the tag's URL attribute. Have a look at the following code:

 <CFIF UserIsLoggedIn IS False>        <CFLOCATION URL="LoginPage.cfm">  </CFIF>

With this code, we can check whether a user has logged in. If he hasn't, we can gently redirect him back to the login page. We will be using this tag along with the IsDefined() function to help keep our users on track.


    Team-Fly    
    Top
     



    ColdFusion MX. From Static to Dynamic in 10 Steps
    ColdFusion MX: From Static to Dynamic in 10 Steps
    ISBN: 0735712964
    EAN: 2147483647
    Year: 2002
    Pages: 140
    Authors: Barry Moore

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net