|
LiveMotion Forms - Part IV
Setting up our CFML Script.
Carl Calder from New Motion Designs was kind enough to setup this
CFML Script for the Simple form. Remember, you need to have Cold
Fustion installed on your server for this code to work. Below
is the code and Carl's description.
--- CODE ---
<cfsetting
enablecfoutputonly="YES">
<cfset useremail=txtEmail>
<cfset username=txtName>
<cfset userURL=txtURL>
<cfset usercomments=txtComments>
<cfmail from="#useremail#" to="yourname@yoursite.com"
cc="#useremail#" subject="Form response from New
Motion Designs">
This is an email saying that: #username#
from: #userURL#
return email: #useremail#
gave the following comments to the form at New Motion Designs.
#usercomments#</cfmail>
<cfset toflash="&txtStatus=Thank you. Form has been
successfully sent!&">
<cfoutput>#toflash#</cfoutput>
--- CODE ---
OK...here goes! The beginning set of code establishes the variables
for the CFM code. <cfset useremail=txtEmail>
collects the variable from the txtEmail and inserts it into CFM
as useremail. Same with the others but the values obviously change.
The <cfsetting enablecfoutputonly="YES">
sets the page as an output only page. The <cfmail
from=" " to=" " cc=" " subject="
"> all work as I explained in the previous email
to you and need to be one line of code. This, to recap, is where
the programmer enters the email information. You can add the variable
#useremail# into the
to=" " or cc=" " and have a copy of
the email sent to them for confirmation or as an acceptance type
thing. Whatever you would like. They can also be changed to have
a set email and not return to the user.
After the <cfmail > tag is
the email body and can be modified for any text they want and
have the user input respond in the needed locations by again wrapping
the cfset variable with # and #. The body of the mailer is ended
with </cfmail>.
Now for the part that has been updated since the last email I
sent you.... The <cfset toflash="&txtStatus=your
text here&"> sets your status message to return
to the flash form. The <cfoutput>#toflash#</cfoutput>
actually sends the variable back to the flash form. The <cfoutput>
will not be sent if there is an error on the page.
My next project (other than the guestbook) is to setup a IF ELSE
statement to send an error message if the mailer does encounter
an error and does not send.
Remember, I am by no means a CFM expert and If someone more qualified
gives a better way or explanation, take it. LOL. You can test
the way I have this set up by going to http://www.newmotiondesigns.com/liv/motion2.html
and choosing the feedback then the form page from the menu trying
it yourself. PLEASE remember that this site is under construction
so please be gentle with the critique.
If your only doing the CFML script, skip to the end of this tutorial
part
1
2
3
4
5
6
|