home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfinsert.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.2 KB  |  74 lines

  1. <!--- This example shows how to use CFINSERT instead of CFQUERY
  2. to place data into a datasource. --->
  3.  
  4. <!--- if form.POSTED exists, we are inserting a new record,
  5. so begin the CFINSERT tag --->
  6. <!--- Under UNIX you must add CommentID to the FORMFIELDS --->
  7. <CFIF IsDefined ("form.posted")>
  8.   <CFIF Server.OS.Name IS "Windows NT">
  9.     <CFINSERT DATASOURCE="cfsnippets"
  10.       TABLENAME="Comments"
  11.       FORMFIELDS="EMail,FromUser,Subject,MessText,Posted">
  12.   <CFELSE>
  13.       <CFINSERT DATASOURCE="cfsnippets"
  14.       TABLENAME="Comments"
  15.       FORMFIELDS="CommentID,EMail,FromUser,Subject,MessText,Posted">
  16.   </CFIF>
  17. <H3><I>Your record was added to the database.</I></H3>
  18. </CFIF>
  19.  
  20. <!--- use a query to show the existing state of the database --->
  21. <CFQUERY NAME="GetComments" DATASOURCE="cfsnippets">
  22. SELECT     CommentID, EMail, FromUser, Subject, CommtType, MessText, Posted, Processed
  23. FROM       Comments
  24. </CFQUERY>
  25.  
  26. <HTML>
  27. <HEAD>
  28. <TITLE>CFINSERT Example</TITLE>
  29. </HEAD>
  30.  
  31. <BODY bgcolor="silver">
  32. <H3>CFINSERT Example</H3>
  33.  
  34. <P>First, we'll show a list of the available comments in the cfsnippets datasource.
  35.  
  36. <!--- show all the comments in the db --->
  37. <TABLE>
  38.     <TR>
  39.         <TD>From User</TD><TD>Subject</TD><TD>Comment Type</TD><TD>Message</TD><TD>Date Posted</TD>
  40.     </TR>
  41. <CFOUTPUT query="GetComments">
  42.     <TR>
  43.         <TD valign=top><a href="mailto:#EMail#">#FromUser#</A></TD>
  44.         <TD valign=top>#Subject#</TD>
  45.         <TD valign=top>#CommtType#</TD>
  46.         <TD valign=top><FONT SIZE="-2">#Left("#MessText#", 125)#</FONT></TD>
  47.         <TD valign=top>#Posted#</TD>
  48.     </TR>
  49. </CFOUTPUT>
  50. </TABLE>
  51.  
  52. <P>Next, we'll offer the opportunity to enter your own comment:
  53.  
  54. <!--- make a form for input --->
  55. <FORM ACTION="cfinsert.cfm" METHOD="POST">
  56. <!--- dynamically determine today's date --->
  57. <INPUT TYPE="Hidden" NAME="posted" VALUE="<CFOUTPUT>#Now()#</CFOUTPUT>">
  58. <PRE>
  59. Email:    <INPUT TYPE="Text" NAME="EMail">
  60. From:    <INPUT TYPE="Text" NAME="FromUser">
  61. Subject:<INPUT TYPE="Text" NAME="Subject">
  62. Message:<TEXTAREA NAME="MessText" COLS="40" ROWS="6"></TEXTAREA>
  63.  
  64. Date Posted:    <CFOUTPUT>#DateFormat("#Now()#")#</CFOUTPUT>
  65. </PRE>
  66. <BR>
  67. Comment ID <B>(UNIX server only)</B>:    <INPUT TYPE="Text" NAME="CommentID">
  68. <P>
  69. <INPUT TYPE="Submit" VALUE="Insert My Comment">
  70. </FORM>
  71.  
  72. </BODY>
  73. </HTML>       
  74.