MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual page 144

Developing web applications with coldfusion
Table of Contents

Advertisement

118
<!--- Call the custom tag that adds employees --->
<CF_ADDEMPLOYEE EMPINFO="#employee#">
</CFIF>
<HR>
<FORM ACTION="structinsert.cfm" METHOD="Post">
<P>First Name:&nbsp;
<INPUT NAME="firstname" TYPE="text" HSPACE="30" MAXLENGTH="30">
<P>Last Name:&nbsp;
<INPUT NAME="lastname" TYPE="text" HSPACE="30" MAXLENGTH="30">
<P>EMail:&nbsp;
<INPUT NAME="email" TYPE="text" HSPACE="30" MAXLENGTH="30">
<P>Phone:&nbsp;
<INPUT NAME="phone" TYPE="text" HSPACE="20" MAXLENGTH="20">
<P>Department:&nbsp;
<INPUT NAME="department" TYPE="text" HSPACE="30" MAXLENGTH="30">
<P>
<INPUT TYPE="Submit" VALUE="OK">
</FORM>
</BODY>
</HTML>
Example file addemployee.cfm
<P>This file is an example of a custom tag used
to add employees. Employee information is passed
through the employee structure (the EMPINFO attribute).
In UNIX, you must also add the Emp_ID.
<CFSWITCH EXPRESSION="#ThisTag.ExecutionMode#">
<CFCASE VALUE="start">
<CFIF StructIsEmpty(attributes.EMPINFO)>
<CFOUTPUT>Error. No employee data was passed.</CFOUTPUT>
<CFEXIT METHOD="ExitTag">
<CFELSE>
<!--- Add the employee --->
<!--- In UNIX, you must also add the Emp_ID --->
<CFQUERY NAME="AddEmployee" DATASOURCE="cfsnippets">
INSERT INTO Employees
(FirstName, LastName, Email, Phone, Department)
VALUES
<CFOUTPUT>
(
'#StructFind(attributes.EMPINFO, "firstname")#' ,
'#StructFind(attributes.EMPINFO, "lastname")#' ,
'#StructFind(attributes.EMPINFO, "email")#' ,
'#StructFind(attributes.EMPINFO, "phone")#' ,
'#StructFind(attributes.EMPINFO, "department")#'
Developing Web Applications with ColdFusion

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents