After the form data is entered and validated, it is pushed to the action page for processing. You can use FORM variables on the action page in much the same way that you would use URL or even local variables. Consider this example: <cfquery name="GetEmployees" datasource="MyDSN"> SELECT * FROM Employees WHERE EmployeeID = #FORM.EmployeeID# </cfquery> FORM variable name=value pairs for text boxes, text areas, and drop-down lists always exist on the action page even if the user didn't enter any information. For instance, if a text box named FName was left empty upon form submission, the action page would get FName=. This point is important because some form controlsnamely checkboxes, radio buttons, multiple select controls, and submit buttons that are not clickedare not passed at all if they are not selected. So if a form has a set of checkboxes named FavColor, and the user doesn't check any of them, nothing is sent to the action page. It is very important that you do the following on your action page:
<cfparam> was introduced in Chapter 2, "Working with Variables and Expressions." TIP We've stated before that it is always a good idea to prefix your ColdFusion variables. However, it's OK not to prefix your variables if you want to intentionally leave your code flexible. For instance, consider this example: <cfquery name="GetEmployees" datasource="MyDSN"> SELECT * FROM Employees WHERE EmployeeID = #EmployeeID# </cfquery> If this code were in the action page, it could use either a FORM variable or a URL variable in the WHERE statement. |