22.08.2013 Views

ColdFusion Developer's Guide

ColdFusion Developer's Guide

ColdFusion Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />

Reviewing the code<br />

The following table describes the code:<br />

Code Description<br />

<br />

<br />

<br />

<br />

<br />

<br />

Please fill out the form.<br />

<br />

<br />

<br />

employee=StructNew();<br />

employee.firstname = Form.firstname;<br />

employee.lastname = Form.lastname;<br />

employee.email = Form.email;<br />

employee.phone = Form.phone;<br />

employee.department = Form.department;<br />

<br />

First name is #employee.firstname#<br />

Last name is #employee.lastname#<br />

EMail is #employee.email#<br />

Phone is #employee.phone#<br />

Department is #employee.department#<br />

<br />

138 Using Arrays and Structures<br />

Set default values of all form fields so<br />

that they exist the first time this page is<br />

displayed and can be tested.<br />

Test the value of the form’s firstname<br />

field. This field is required. The test is<br />

False the first time the page displays.<br />

If there is no data in the Form.firstname<br />

variable, display a message requesting<br />

the user to fill the form.<br />

If Form.firstname contains text, the user<br />

submitted the form.<br />

Use CFScript to create a new structure<br />

named employee and fill it with the form<br />

field data.<br />

Then display the contents of the<br />

structure

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!