<!--- This example shows how to use CFINSERT instead of CFQUERY
to place data into a datasource. --->


<!--- if form.POSTED exists, we are inserting a new record,
so begin the CFINSERT tag --->
<!--- Under UNIX you must add CommentID to the FORMFIELDS --->
<!---<CFIF IsDefined ("form.posted")>
  <CFIF Server.OS.Name IS "Windows NT">
    <CFINSERT DATASOURCE="cfsnippets"
	  TABLENAME="Comments"
	  FORMFIELDS="EMail,FromUser,Subject,MessText,Posted">
  <CFELSE>
	  <CFINSERT DATASOURCE="cfsnippets"
	  TABLENAME="Comments"
	  FORMFIELDS="CommentID,EMail,FromUser,Subject,MessText,Posted">
  </CFIF>
<H3><I>Your record was added to the database.</I></H3>
</CFIF>

<!--- use a query to show the existing state of the database --->
<CFQUERY NAME="GetComments" DATASOURCE="cfsnippets">
SELECT     CommentID, EMail, FromUser, Subject, CommtType, MessText, Posted, Processed
FROM       Comments
</CFQUERY> --->

<HTML>
<HEAD>
<TITLE>CFINSERT Example</TITLE>
</HEAD>

<BASEFONT FACE="Arial, Helvetica" SIZE=2>

<BODY  bgcolor="#FFFFD5">
<H3>CFINSERT Example</H3>
This is a read-only example. Because database access
is a sensitive area, consider the security of your database before 
allowing people to insert, update, or delete data from it.

<P>First, we'll show a list of the available comments in the cfsnippets datasource.

<!--- show all the comments in the db --->
<!---<TABLE>
	<TR>
		<TD>From User</TD><TD>Subject</TD><TD>Comment Type</TD><TD>Message</TD><TD>Date Posted</TD>
	</TR>
<CFOUTPUT query="GetComments">
	<TR>
		<TD valign=top><a href="mailto:#EMail#">#FromUser#</A></TD>
		<TD valign=top>#Subject#</TD>
		<TD valign=top>#CommtType#</TD>
		<TD valign=top><FONT SIZE="-2">#Left(MessText, 125)#</FONT></TD>
		<TD valign=top>#Posted#</TD>
	</TR>
</CFOUTPUT>
</TABLE>

<P>Next, we'll offer the opportunity to enter your own comment:

<!--- make a form for input --->
<FORM ACTION="cfinsert.cfm" METHOD="POST">
<!--- dynamically determine today's date --->
<INPUT TYPE="Hidden" NAME="posted" VALUE="<CFOUTPUT>#Now()#</CFOUTPUT>">
<PRE>
Email:	<INPUT TYPE="Text" NAME="EMail">
From:	<INPUT TYPE="Text" NAME="FromUser">
Subject:<INPUT TYPE="Text" NAME="Subject">
Message:<TEXTAREA NAME="MessText" COLS="40" ROWS="6"></TEXTAREA>

Date Posted:	<CFOUTPUT>#DateFormat(Now())#</CFOUTPUT>
</PRE>
<BR>
Comment ID <B>(UNIX server only)</B>:	<INPUT TYPE="Text" NAME="CommentID">
<P>
<INPUT TYPE="Submit" VALUE="Insert My Comment">
</FORM> 
 --->
</BODY>
</HTML>       
