User Guide

Working with Action Pages 45
Working with Action Pages
A ColdFusion action page is just like any other application page except that you can
use the form variables that are passed to it from an associated form. The following
sections describe how to create effective action pages.
Processing form variables on action pages
The action page gets a form variable for every form control that contains a value
when the form is submitted.
Note
If multiple controls have the same name, one form variable is passed to the action
page. It contains a comma-delimited list.
A form variables name is the name that you assigned to the form control on the form
page. Refer to the form variable by name within tags, functions, and other
expressions on an action page.
Because Form variables extend beyond the local pagetheir scope is the action
pageprefix them with Form. to explicitly tell ColdFusion that you are referring to
a form variable. For example the following code references the LastName form
variable for output on an action page:
<cfoutput>
#Form.LastName#
</cfoutput>
Dynamically generating SQL statements
As you have already learned, you can retrieve a record for every employee in a
database table by composing a query like this:
<cfquery name="GetEmployees" datasource="CompanyInfo">
SELECT FirstName, LastName, Contract
FROM Employee
</cfquery>
But when you want to return information about employees that match user search
criteria, you use the SQL WHERE clause with a SQL SELECT statement to compare a
value against a character string field. When the WHERE clause is processed, it filters
the query data based on the results of the comparison.
For example, to return employee data for only employees with the last name of
Smith, you build a query that looks like this:
<cfquery name="GetEmployees" datasource="CompanyInfo">
SELECT FirstName, LastName, Contract
FROM Employee
WHERE LastName = "Smith"
</cfquery>