Preparing the ColdFusion Pages
In this task, you'll prepare the dante_quiz_login.cfm page and the dante_quiz_questions.cfm page. You'll complete the third pagedante_quiz_results.cfmin Lesson 16.
1. | Open dante_quiz_login.cfm in Dreamweaver. Add three paragraphs of text, as follows, to the main body of the document. After the second line, press Enter/Return twice before adding the last line. Link the word Return to index.cfm .Take this ungraded quiz to see how well you've mastered the material. |
The third line is supposed to be blank; that's where you'll add the form in a moment.[View full size image]

2. | Switch to either code view or split view for the following steps. Select the code between the opening and closing <p></p> tags which form the blank line you created in the previous step. |
The code represents a non-breaking space, and was inserted by Dreamweaver to give content to the paragraph you created for the blank line. As you'll recall, it's considered ba217 form to have tags that lack content, such as opening and immediately closing <p></p> tags. The non-breaking space is invisible, so it doesn't mess up your pagebut it's technically content, so th218 is still well formed.[View full size image]

3. | Use the CFForm category of the Insert bar to insert a CF Form. The cfform tag editor will open. In the General category, set the Action to dante_quiz_questions.cfm, the Method to post, and the name to frm_login . Select the Miscellaneous category and set the Format to Flash. You can choose a Skin at this time to give your form a particular look. Click OK to close the tag editor . |
This step creates the basic functionality of the form. Now all the form needs is a field to enable the user to enter her or his username, and a Submit button so she or he can submit the form.[View full size image]

[View full size image]


5. | To complete the form, you must insert a Submit button. With the cursor at the end of the first <cfinput> tag, press Enter/Return to make room for another form input. Insert another CF Text field from the insert bar. The cfinput tag editor opens. Set the Type to submit, and both the name and value to Submit . Click OK to close the tag editor . |
The form is now ready for use.[View full size image]

6. | Save, Put, and Close dante_quiz_login.cfm . |
It's easy to forget to Put files when you're finished working on them, so get in the habit of putting files just before you close them.
7. | Open dante_quiz_questions.cfm. In the Bindings panel, select New Binding (+) > Form Variable. In the Form Variable dialog, name it username . |
As before, creating the binding tells Dreamweaver how to find data that you expect to be available to the page.

8. | Replace the placeholder body text with You logged in as: and press Enter/Return once to create a new paragraph beneath it . |
You'll dynamically output the username after the colon in the first line, and you'll insert the Flash movie in the second line.[View full size image]

9. | From the Bindings panel, press and drag the username variable onto the page, to the right of the colon in the first line . |
As before, Dreamweaver writes a <cfoutput> tag into the code. At runtime, ColdFusion will replace <cfoutput>#form.username#</cfoutput> with the email address entered into the form on dante_quiz_login.cfm.[View full size image]


11. | Click to select the Flash movie, and switch to code view . |
If you look at the code, you'll see the Flash movie's URL referenced twice. Inserting Flash movies int228 pages requires a bit of redundancy, because Internet Explorer deals with media players like the Flash player differently than Netscape and other browsers. Specifically, th218 includes both the <object> and <embed> tags, which are used to insert special media files into browsers. Both tags require that you specify the URL pointing to the plug-in file (in this case, a Flash SWF).[View full size image]

flash/dante_quiz.swf?username=yuki@sheepman.comThe question mark separates the file from the variable(s). In this case, only one namevalue pairing follows. The only catch is that you don't know the value in advance; you'll need to capture the username entered into the form. This problem can also be resolved with the ever-useful <cfoutput> tag.
12. | In code view, append ?username=<cfoutput>#form.username#</cfoutput> to each of the two URLs. Each URL should read as follows: "flash/dante_quiz.swf?username=<cfoutput>#form.username#</cfoutput>" |
The <cfoutput> block will be resolved before the page is sent back to the browser, so by the time the Flash movie is requested, the correct data will already exist and be inserted into the Flash movie.[View full size image]

13. | Save and Put dante_quiz_questions.cfm. Also, be sure to Put flash/dante_quiz.swf . |
You're ready to test this portion of the pages/movie.
14. | Select dante_quiz_login.cfm in the Files panel, and press F12 (Windows) or Option+F12 (Macintosh). Enter an email address in the form and click Submit . |
The second page, dante_quiz_questions.cfm, should load, and the Flash movie with it.The username variable should be resolved in both the regular page and the Flash movie.