Chapter 6: Updating Your Data
</HTML>
3.
Save the file as
4.
View
Data Entry Form Notes and Considerations
Creating data entry fields for an HTML form is very simple:
You need only create the HTML form fields for each database field into which
you want to insert data.
The names of your form fields must be identical to the names of your database
fields.
You can use the full range of HTML input controls, including list boxes, radio
buttons, checkboxes, and multi-line text boxes in your forms.
ColdFusion uses the NAME attribute to map HTML form fields to the
corresponding database fields and inserts the data entered by the user into the
appropriate database fields.
Creating an Action Page to Insert Data
There are two ways to create an action page to insert data into a database.
The CFINSERT tag is the easiest way to handle simple inserts from either a CFFORM or
an HTML form.
For more complex inserts from a form submittal you can use a SQL INSERT statement
in a CFQUERY tag instead of a CFINSERT tag. The SQL INSERT statement is more
flexible because you can insert information selectively or use functions within the
statement.
To create an insert action page with CFINSERT:
1.
Create a new application page in Studio.
2.
Enter the following code:
4
<CFINSERT DATASOURCE="CompanyInfo" TABLENAME="Employees">
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>Employee Added</H1>
<CFOUTPUT>
You have added #Form.FirstName# #Form.LastName# to the Employees
database.
</CFOUTPUT>
</BODY>
</HTML>
insertform.cfm
in a browser.
insertform.cfm
<TITLE>Input Form</TITLE>
in the
directory.
myapps
61
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?
Questions and answers