User Guide

Table Of Contents
Inserting data 477
<td><input type="Text" name="Dept_ID" size="4" maxlength="4"></td>
</tr>
<tr>
<td>Start Date:</td>
<td><input type="Text" name="StartDate" size="16" maxlength="16"></td>
</tr>
<tr>
<td>Salary:</td>
<td><input type="Text" name="Salary" size="10" maxlength="10"></td>
</tr>
<tr>
<td>Contractor:</td>
<td><input type="checkbox" name="Contract" value="Yes" checked>Yes</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="Submit" value="Submit">&nbsp;<input type="Reset"
value="Clear Form"></td>
</tr>
</form>
<!--- end html form --->
</table>
</body>
</html>
2.
Save the file as insert_form.cfm in the myapps directory under your web_root and view it in your
web browser.
Note: The form will not work until you write an action page for it. For more information, see “Creating
an action page to insert data” on page 477.
Data entry form notes and considerations
If you use the
cfinsert tag in the action page to insert the data into the database, you should
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 inserts all of the forms fields into the database columns with the same
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 formfields attribute of the cfinsert tag to specify which fields to insert;
for example,
formfields="prod_ID,Emp_ID,status".
Creating an action page to insert data
You can use the
cfinsert tag or the cfquery tag to create an action page that inserts data into a
database.