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:


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 the O’Reilly learning platform.

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