Explore the Premium Content

ColdFusion MX: Securing Your Application

In the last article we built out the back-end administration of the website in CFForms & Administration (Part 2 of 2).  We had already built the tools to allow people to put stuff into the database, so we built a way to get things out of the database.  Our goal was to build the framework for our back-end, and build one tool that allowed us to report off the sales leads.  The last article was full of great tips, additional use of Dreamweaver code wizards and we also spent a great deal of time explaining the code that we used as well.  One such example is that we introduced recordset paging and recordset navigation.  These two useful tools allow you to be informed on what records you’re viewing, and a means to navigate through all the records being returned.

In this article we want to secure what we’ve created so that only people with the right login, password and security role can log in and interact with the back-end admin section.  We will focus our attention on the Application framework, the Application.cfm file, Application variables and how to secure your website with a login and password using <cflogin>, <cfloginuser>, <cflogout> as well as some related functions: GetAuthUser() and IsUserInRole()

Read More

Introduction to Coldfusion Components

Introduction

Coldfusion Components also known as CFC’s. A lot of people I know who program Coldfusion and not use CFC’s have as excuse; it’s too hard to learn! It’s too hard to learn?? No way!!

It’s very easy to learn. It’s just an other way of thinking than you’re used to. You must see CFC’s as building blocks. By constructing “building blocks” you’re code is much cleaner and far more reusable, thus quicker to build your application. Most (if not every) Coldfusion developer knows UDF’s (User Defined Functions) and Custom Tags. CFC’s are almost the same as Custom Tags, but have some differences:

  • Custom Tags have a single entry point; CFC’s can have multiple entry points. This makes it possible to create a single component that does many related actions. (To do that with custom tags you would need multiple tags or cumbersome switch processing.)
  • Custom Tags have no formalized parameters passing and validation mechanism; CFC’s do. In other words unlike custom tags, CFC’s can validate passed data, enforce data types, check for required parameters, and optionally assign default values.
  • Custom Tags cannot persist; CFC’s can. Custom Tags are blocks of code that are executed as is, while CFC’s are objects and can be treated as such.
  • Custom Tags are designed to contain code; CFC’s are designed to contain both code and data.
  • Custom Tags are accessible only by Coldfusion and only locally; CFC’s can be accessed as web services, opening up a whole new world of reuse possibilities.

To sum it up, CFC’s and Custom Tags are quite different. Although their functionality does overlap a little, they really do not solve the same problems at all. So to learn the basics of CFC’s while head right on it and start with some sample “spaghetti code” and transform it to a structured and reusable way; a CFC. Please note that this article only covers the basics of CFC’s and does not handle any advanced topics.

Read More
FREE

Free! - Selecting Records per Page with the Horizontal Looper Behaviour

This tutorial shows how to let the visitor select the number of records per page from a List Box using Tom Muck’s Horizontal Looper Extension.

Since there will be probably be several pages on your site with this behaviour, we are going to use a Session to store the visitor’s choice so it will be valid on all the pages, instead of the visitor having to set the number of records on each page they visit.

Read More

Coldfusion MX 7: Performance tuning

In this tutorial we’re going to talk about performance tuning your Coldfusion application. Some of the performance tips are compatible with Coldfusion MX 6.x, but most of the performance tips are Coldfusion MX 7 only features. We’re going to talk about query/database performance, caching your pages and finding the “bottle necks” in your application.

Read More

ColdFusion MX: CFForms and Back-End Administration (part 2 of 2)

ColdFusion MX: CFForms and Back-End Administration (part 2 of 2)

In the last article (part 1) we went through all the different types of server-side as well as client-side validation of data submitted by a form.  We even exposed some of the JavaScript that is written by ColdFusion when using <cfform> and <cfinput> together.  We also looked at the key differences between server-side validation and client-side validation as a best approach to how to build your next form / action page application.  I was hoping to get into the Back-End Administration construction but my article got too big and ran out of time to “Git-'R-Done!"

In this article we’re picking up where we left off to build out the back-end administration of the website.  This is a good time to begin it since we’ve added some front-end capabilities that work with a database.  It stands to reason that if we allow people to put stuff into the database, we better have a way to get things out of the database.  Our goal is to build the framework for our back-end, and build one tool that will allow us to report off the sales leads.  We’ll have a search interface so we can pull database records based on form criteria supplied by an admin user.  We’ll automatically pull the top 10 most recent records and make the table display columns clickable so the user can sort the data they’re seeing by ascending and descending order on the column itself.  We’re going to use some of the ColdFusion code wizards in Dreamweaver MX 2004, and we’ll look at some intermediate to advanced-level ColdFusion code suitable for a beginner.  One such example is that we will introduce recordset paging and recordset navigation.  These two useful tools allow you to be informed on what records you’re viewing, and a means to navigate through all the records being returned.

Read More

ColdFusion MX: CFForms and Back-End Administration part 1

ColdFusion MX: CFForms and Back-End Administration (part 1 of 2)

In the last article we began to build a web application using forms to insert records into a MySQL database.  The concept was simple, we had potential customers that were interested in a vacation from our OKCTravel.com website and they used a form to have their information and interests stored in a database.  I gave an overview on HTML forms as well as the SQL for an insert statement and how to orchestrate a “form page, action page” type of application.

In this article we’d like to expand a little on our forms by introducing CFForms using the <cfform> tag.  Without giving away all of its secrets, ColdFusion will parse your page and create valid JavaScript routines to handle some very common client side validation of your forms.  This is great because end-users will be prompted with JavaScript alert boxes of the things that are incorrect on their form which saves them from having to submit the form to the server to do the checking. 

Here are the topics that we’re going to cover in part 1 of this article:

  • <cfform>
  • <cfinput>
  • Server-Side vs. Client-Side Validation

These topics will give us a chance to explore everything there is to offer about forms and client-side validation in addition to building out our back-end administration (in part 2).  This article will not cover security just yet.  We’re going to build the framework and a working application and perhaps in the next article we’ll discuss securing our application, but by the end of this article series you’ll have a completed framework for your entire website.  When you read this article, don’t forget to grab the source code too – it’s all included just for you!

Read More
FREE

Free! - Coldfusion MX 7, Learning the new features

What’s new in ColdFusion MX 7

Finally a real “developer” version is released of ColdFusion. The release of MX a few years ago was more a performance update by making it a Java based server instead of the “full of memory leaks” C++ version.

With the capabilities of Java, the ColdFusion team managed to create some very helpful features, such as reporting capabilities, FlashPaper 2/PDF creation, Rich Forms, new Charting engine, improved search engine (Verity), Dreamweaver MX 2004 server management integration, Gateways, Administrator API and lots and lots of other features.

So let’s start with one of the, in my eyes, best productivity enhancements, Rich Forms.

Rich Forms

With the ColdFusion Rich Forms you can easily create complex forms, generated in plain HTML, Xforms (XML) or Flash forms. Let’s take a look at an example of a Rich Form in Flash format.

<cfform name="foo" action="process.cfm" method="post" format="flash" skin="haloBlue" width="390" timeout="10" preloader="true">
      <cfformgroup type="tabnavigator">
            <cfformgroup type="page" label="Message Inbox">

ColdFusion MX: Forms

In the previous articles we did a lot of code reuse through many of the tags and devices that ColdFusion gives us in ColdFusion MX: Reusing Code.  That is a bit of an overview on all the things that we can use as a developer to help us architect a great web application.  Now we get to use what is commonly the first thing that makes a web application – Forms.  Forms are the essential part of every website it seems.  In a web application we use a form to collect data from the user, use the form to display editable data from a database back to a user or insert data into the database from the user.

In this article we’d like to build a form application that will collect contact information from a user that is interested travelling to some exotic location.  We’d like to store that data in a database and use things like server-side validation on the form data the user supplies.

We’re going to work with ColdFusion MX and explore the following tasks:

  • HTML Forms
  • The Database
  • ColdFusion & Forms
  • Conditional Processing
  • <cflocation>

These topics will give us a chance to explore everything there is to explore about forms from the standpoint of collecting data from a user and inserting into a database.  This will be essential to other upcoming articles when we want to reverse the process by taking information back out of a database and putting them into forms for a user to insert, update or even delete database data.

Read More

How to validate forms with VBScript Part 1

Introduction

For those of us that lean towards VBScript rather than JavaScript, form validation can be just as rewarding, well functional using VBScript.

As with all scripting languages there always seems to be many ways of achieving the same result so I picked the most simple and logical methods of validating form fields.

When to do the validating

The usual time and place to validate your form data is when the user has completed a form and is ready to submit that data for processing. Of course there are times when validation needs to take place before the user gets that far but we will cover that later on.

As a general rule, we will perform our validation when submission occurs and either stop the process if part of our validation criteria has not been met or let the process continue if everything is as we want.

So the trigger for our validation event will be on Submission or in VBScript language onSubmit (See how friendly VBScript can be?)

Read More

Building Your Own RSS Feed with Dreamweaver

RSS is a method of syndicating your content to other web sites and users. It provides a summary of your content in a compact XML-based form. If you read Weblogs, you've probably encountered them, as most blog generate them so that friends can share their recent posts easily across different systems. If you're using Mozilla, you can bookmark RSS feeds to easily keep up with the latest headlines from your favourite websites. Other sites with a similar interest can use RSS to show your headlines and send you interested traffic. Alternatively you can use a program called an RSS Aggregator (like the one at http://www.feedreader.com/) to keep track of all your favourite headlines:



In this tutorial we'll look at how to create an RSS feed in Dreamweaver MX 2004, using the PHP Server Model. It assumes a basic familiarity with the PHP Server Model, since it doesn't include the basics of setting up the site or database.

Read More

ColdFusion MX: Reusing Code

In the last two articles (ColdFusion MX Installation & Basic Testing and ColdFusion MX: Displaying Database Data) we did a lot of setup for our working environment, and we were able to retrieve records from a MySQL database to display on the screen.  At this point when you’re ready to start writing more code, it’s a good time to learn about code re-use in ColdFusion MX.

The basic mantra of all developers is “write it once, use it many times”.  There are many reasons why we try to reuse the code we write such as lower maintenance, site/application consistent look and feel and even a layer of abstraction where we can separate our business logic of our application from the user interface.

ColdFusion MX gives us several devices for reusing code.  In this article, I’d like to touch on all of the code reuse tools that are available to us.

In this article, we’re going to work with ColdFusion MX and explore the following tasks:

·         The <cfinclude> tag

·         ColdFusion Mappings

·         Custom Tags

·         User-Defined Functions

·         ColdFusion Components (CFCs)

·         Code reuse best practices

These are the basic tools available to us for code reuse in ColdFusion MX.  Often times, we use these tools to help us with our application architecture.   Much can be written on any one of these topics and here I’d like to give good introductory examples on each so you can begin using them right away in your applications.

Read More

ColdFusion MX: Displaying Database Data

In my previous article we set up our ColdFusion MX environment, learned some basics on ColdFusion and created a sample page using some simple tags and functions.  The page itself was a fancy “hello world” example with few lines of code. 

The truly great thing I love about ColdFusion is that you can do really great things with few lines of code.  One of the things that impressed me most was how easy it was to retrieve information from a database and display that data.  Even though ColdFusion has changed so much over the years, it’s still very simple to connect to a database, retrieve data and display that data.  This is what we will accomplish in this article.

In this article, we’re going to work with ColdFusion MX and explore the following tasks:

  • Deciding on the database: MySQL 4.1.8 & MySQL Administrator (for Windows)
  • Installing MySQL and MySQL Administrator
  • Setting up the Database
  • Creating the Data Source Name (DSN)
  • Querying a Database Table
    • Basic Select Statement
    • Using the CFDump tag
    • Dreamweaver Recordset Builder
    • Understanding the Result Set
  • Displaying Database Data
  • Dynamic Table Tool
  • Additional Query Information

These are the basic tasks necessary to setting up a database for use and then writing ColdFusion code to query that database and display data.  You will see some insight into the dot notation that is being used in ColdFusion as well as additional information about MySQL and recordsets.

Read More