home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / addemployee.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.1 KB  |  50 lines

  1. <!--- This is an example of a custom tag used
  2.       to add employees. Employee information is passed
  3.       through the employee structure (the EMPINFO attribute. --->
  4. <!--- 
  5. This is a read-only example, because access to a database
  6. is a sensitive area. Consider the security of your database before 
  7. allowing access to it.
  8.  
  9. <cfswitch expression="#ThisTag.ExecutionMode#">
  10.    <cfcase value="start">
  11.       <CFIF StructIsEmpty(attributes.EMPINFO)>
  12.         <CFOUTPUT>Error. No employee data was passed.</cfoutput>
  13.           <CFEXIT METHOD="ExitTag">
  14.         <cfelse>
  15.           <!--- Add the employee --->
  16.           <!--- In UNIX, you must also insert the Emp_ID (Long) --->
  17.            <CFQUERY NAME="AddEmployee" datasource="cfsnippets">
  18.             <CFIF Server.OS.Name EQ "Windows NT">
  19.                INSERT INTO Employees(FirstName, LastName, EMail, Phone, Department)
  20.                VALUES 
  21.                 <CFOUTPUT>
  22.                   (
  23.                     '#StructFind(attributes.EMPINFO, "firstname")#' ,
  24.                     '#StructFind(attributes.EMPINFO, "lastname")#' ,
  25.                     '#StructFind(attributes.EMPINFO, "email")#' ,
  26.                     '#StructFind(attributes.EMPINFO, "phone")#' ,
  27.                     '#StructFind(attributes.EMPINFO, "department")#'
  28.                    )
  29.                 </cfoutput>
  30.             <CFELSE> 
  31.               INSERT INTO Employees(Emp_ID, FirstName, LastName, EMail, Phone, Department)
  32.                VALUES 
  33.                 <CFOUTPUT>
  34.                   (
  35.                     '#StructFind(attributes.EMPINFO, "empid")#' ,
  36.                     '#StructFind(attributes.EMPINFO, "firstname")#' ,
  37.                     '#StructFind(attributes.EMPINFO, "lastname")#' ,
  38.                     '#StructFind(attributes.EMPINFO, "email")#' ,
  39.                     '#StructFind(attributes.EMPINFO, "phone")#' ,
  40.                     '#StructFind(attributes.EMPINFO, "department")#'
  41.                    )
  42.                 </cfoutput> 
  43.             </cfif>
  44.           </cfquery>
  45.         </cfif>
  46.       <CFOUTPUT><HR>Employee Add Complete</cfoutput>
  47.    </cfcase>
  48. </cfswitch>
  49.  
  50.  --->