Data Entry Form Notes And Considerations; Creating An Action Page To Insert Data - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Data entry form notes and considerations

If you use the
cfinsert
follow these rules for creating the form page:
You only need to create HTML form fields for the database columns into which you will insert
data.
By default,
cfinsert
names. For example, it puts the Form.Emp_ID value in the database Emp_ID column. The
tag ignores form fields that lack corresponding database column names.
Note: You can also use the
for example,
formfields="prod_ID,Emp_ID,status"

Creating an action page to insert data

You can use the
database.
Creating an insert action page with cfinsert
The
tag is the easiest way to handle simple inserts from either a
cfinsert
form. This tag inserts data from all the form fields with names that match database field names.
To create an insert action page with cfinsert:
Create a ColdFusion page with the following content:
1
<html>
<head> <title>Input form</title> </head>
<body>
<!--- If the Contractor check box is clear,
set the value of the Form.Contract to "No" --->
<cfif not isdefined("Form.Contract")>
<cfset Form.Contract = "No">
</cfif>
<!--- Insert the new record --->
<cfinsert datasource="CompanyInfo" tablename="Employee">
<h1>Employee Added</h1>
<cfoutput>You have added #Form.FirstName# #Form.Lastname# to the
employee database.
</cfoutput>
</body>
</html>
Save the page as insert_action.cfm.
2
View insert_form.cfm in your web browser and enter values.
3
Note: You might wish to compare views of the Employee table in the CompanyInfo data source
before and after inserting values in the form.
Click Submit.
4
ColdFusion inserts your values into the Employee table and displays a confirmation message.
440
Chapter 21: Updating Your Database
tag in the action page to insert the data into the database, you should
inserts all of the form's fields into the database columns with the same
formfields
tag or the
cfinsert
cfquery
attribute of the
cfinsert
.
tag to create an action page that inserts data into a
tag to specify which fields to insert;
or an HTML
cfform

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents