
102
Chapter 7 Updating Your Database
Inserting Data
You usually use two application pages to insert data into a database:
•
An insert form
•
An insert action page
You can create an insert form with standard HTML form tags or with
cfform
tags (see
“Creating Forms with the cfform Tag” on page 136). When the user submits the form,
form variables are passed to a ColdFusion action page that performs an insert
operation (and whatever else is called for) on the specified data source. The insert
action page can contain either a
cfinsert
tag or a
cfquery
tag with a SQL INSERT
statement. The insert action page should also contain a message for the end user.
Creating an HTML insert form
The following procedure creates a form using standard HTML tags.
To create an insert form:
1
Create a new application page in ColdFusion Studio.
2
Edit the page so that it appears as follows:
<html>
<head>
<title>Insert Data Form</title>
</head>
<body>
<H2>Insert Data Form</H2>
<form action="insertaction.cfm" method="post">
Employee ID:
<input type="text" name="Emp_ID" size="4" maxlength="4"><br>
First Name:
<input type="Text" name="FirstName" size="35" maxlength="50"><br>
Last Name:
<input type="Text" name="LastName" size="35" maxlength="50"><br>
Department Number:
<input type="Text" name="Dept_ID" size="4" maxlength="4"><br>
Start Date:
<input type="Text" name="StartDate" size="16" maxlength="16"><br>
Salary:
<input type="Text" name="Salary" size="10" maxlength="10"><br>
Contractor:
<input type="checkbox" name="Contract" value="Yes" checked>Yes<br>
<br>
<input type="Reset" value="Clear Form">
<!-- Submit button -->
<input type="Submit" value="Submit">
</form>
</body>
</html>
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...