Introducing the <CFIF> Tag

To add password protection to Gargantuan's application, you'll use a powerful ColdFusion tag called <CFIF>. <CFIF> is used in conjunction with variables to set up a conditional statement in a template. Essentially, it tells ColdFusion, "If this is true, then do that," leaving it up to you, the developer, to define just what "this" and "that" are.

Conditional statements are used to control ColdFusion processes by stating that before action A can take place, condition B must be satisfied.

First, let's look at a simple if-then construct using <CFIF>. I've designed a basic form that asks a question. The user answers my question by clicking either the True or False link, as shown in Figure 9.1.

Figure 9.1. My sample question ...

Get Sams Teach Yourself ColdFusion® in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.