60
Developing Web Applications with ColdFusion
Inserting Data
Inserting data into a database is usually done with two application pages:
•
An insert form
•
An insert action page
You can create an insert form with CFFORM tags (see
“Creating Forms with the
CFFORM Tag” on page 124
) or with standard HTML form tags. When the form is
submitted, 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
To create an insert form:
1.
Create a new application page in 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="insertdata.cfm" METHOD="Post">
Employee ID:
<INPUT TYPE="text" NAME="Employee_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="10" MAXLENGTH="10"><BR>
Department Number:
<INPUT TYPE="text" NAME="Department_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" NAME="ResetForm" VALUE="Clear Form">
<INPUT TYPE="submit" NAME="SubmitForm" VALUE="Insert Data">
</FORM>
</BODY>
Содержание COLDFUSION 4.5-DEVELOPING WEB
Страница 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Страница 14: ...xiv Developing Web Applications with ColdFusion...
Страница 26: ...xxvi Developing Web Applications with ColdFusion...
Страница 34: ...8 Developing Web Applications with ColdFusion...
Страница 70: ...44 Developing Web Applications with ColdFusion...
Страница 84: ...58 Developing Web Applications with ColdFusion...
Страница 114: ...88 Developing Web Applications with ColdFusion...
Страница 148: ...122 Developing Web Applications with ColdFusion...
Страница 174: ...148 Developing Web Applications with ColdFusion...
Страница 208: ...182 Developing Web Applications with ColdFusion...
Страница 244: ...218 Developing Web Applications with ColdFusion...
Страница 274: ...248 Developing Web Applications with ColdFusion...
Страница 288: ...262 Developing Web Applications with ColdFusion...
Страница 300: ...274 Developing Web Applications with ColdFusion...
Страница 350: ...324 Developing Web Applications with ColdFusion...
Страница 362: ...336 Developing Web Applications with ColdFusion...