Putting It All Together

<cfif> is one of the most frequently used tags in CFML. So before we move on to the next subject, let’s walk through one more example—a slightly more complex one.

Guess the Number is a simple game: I’m thinking of a number between 1 and 10; guess what number I am thinking of. ColdFusion selects a random number, you guess a number, and ColdFusion will tell you whether you guessed the correct one.

Listing 9.6 contains the code for guess1.cfm. Save it in the 9 directory, but don’t execute it from within Dreamweaver. Instead, use this URL to execute it:

http://localhost:8500/ows/9/guess1.cfm?guess=n

Replace n with a number from 1 to 10. For example, if you guess 5, use this URL:

http://localhost:8500/ows/9/guess1.cfm?guess=5 ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.