I have encountered a similar issue with the code below:
When I test the form, the checkboxes do not function as I intend them to. I
want is that if appointment checkbox is selected, an advisor will be notified
via cfmail. If the newsletter checkbox is selected, the visitor's information
will be inserted into a database to receive an newsletter.
I thought the cftransaction tag would solve the problem, but it doesn't. Can
anyone provide an insight as to what I'm doing wrong?
Thank you,
Adam
****************************************************************************
<cfparam name="form.url" default="">
<cfparam name="form.Fname" default="">
<cfparam name="form.Lname" default="">
<cfparam name="form.email" default="">
<cfparam name="form.address1" default="">
<cfparam name="form.address2" default="">
<cfparam name="form.city" default="">
<cfparam name="form.state" default="">
<cfparam name="form.zip" default="">
<cfparam name="form.phone" default="">
<cfparam name="form.enroll" default="">
<cfparam name="form.study" default="">
<cfparam name="form.appointment" default="">
<cfparam name="form.newsletter" default="">
<cfset showForm = true>
<cfif structKeyExists(form, "sendcomments")>
<cfset error = "">
<cfif not len(trim(form.Fname))>
<cfset error = error & "You must include your first name.<br>">
</cfif>
<cfif not len(trim(form.Lname))>
<cfset error = error & "You must include your last name.<br>">
</cfif>
<cfif not isValid("email", form.email)>
<cfset error = error & "Provide a valid email address.<br>">
</cfif>
<cfif not len(trim(form.address1))>
<cfset error = error & "You must include your mailing address.<br />">
</cfif>
<cfif not len(trim(form.city))>
<cfset error = error & "You must include your city.<br />">
</cfif>
<cfif not len(trim(form.state))>
<cfset error = error & "You must include your state.<br />">
</cfif>
<cfif not len(trim(form.zip))>
<cfset error = error & "You must include your zip code.<br />">
</cfif>
<cfif not len(trim(form.phone))>
<cfset error = error & "You must include your phone number.<br />">
</cfif>
<cfif not len(trim(form.enroll))>
<cfset error = error & "You must specify when you enrolled at Ivy
Tech.<br />">
</cfif>
<cfif not len(trim(form.study))>
<cfset error = error & "You must provide your plan of study.<br />">
</cfif>
<cftransaction>
<cfif error is "" and isDefined ('form.appointment')>
<cfmail to="departmentEmail" from="#form.email#"
cc="#form.email#" subject="Appointment" wraptext="75" type="html">
This message was sent by an automatic mailer regarding:
<br />
Appointment
<br />
#form.Fname# #form.Lname# would like to shedule an
appointment with you.
<br />
Email: #Form.Email#<br />
Phone: #Form.Phone#<br />
Address: #Form.Address1# #Form.Address2# #form.City#
#form.State# #form.Zip#<br />
Enrollment Date: #form.Enroll#<br />
Plan of Study: #form.study#<br />
Submitted: <cfoutput>#DateFormat (Now())#, #TimeFormat
(Now())#</cfoutput>
</cfmail>
<cfset showForm = false>
<cfelseif error is "" and isDefined ('form.newsletter')>
<cfquery name="UpdateNewsletter" datasource="myDSN">
INSERT INTO dbo.table (DATE, FNAME, LNAME, EMAIL, ADDRESS,
CITY, STATE, ZIP, PHONE)
VALUES ('#now()#', '#Form.fname#', '#Form.lname#',
'#Form.email#', '#Form.address1#', '#Form.address2#', '#Form.City#',
'#Form.State#', '#Form.Zip#', '#Form.Phone#')
</cfquery>
<cfset showForm = false>
</cfif>
</cftransaction>
</cfif>
<cfif showForm>
<cfif structKeyExists(variables, "error")>
<cfoutput>
<p><strong>Please correct these errors:<br />
#error#
</strong>
</p>
</cfoutput>
</cfif>
<cfoutput>
<cfform action="#CGI.SCRIPT_NAME#" method="post"
enctype="multipart/form-data">
<table>
<tr>
<cfinput type="hidden" name="url" value="#form.url#"><cfinput
type="hidden" name="time" value="#now()#">
<td align="right">First Name:</td>
<td><cfinput type="text" name="Fname"
value="#form.Fname#"></td>
</tr>
<tr>
<td align="right">Last Name:</td>
<td><cfinput type="text" name="Lname"
value="#form.Lname#"></td>
</tr>
<tr>
<td align="right">Email:</td>
<td><cfinput type="text" name="email"
value="#form.email#"></td>
</tr>
<tr>
<td align="right">Address:</td>
<td><cfinput type="text" name="address1"
value="#form.address1#"></td>
</tr>
<tr>
<td align="right">Address:</td>
<td><cfinput type="text" name="address2"
value="#form.address2#"></td>
</tr>
<tr>
<td align="right">City:</td>
<td><cfinput type="text" name="city"
value="#form.city#"></td>
</tr>
<tr>
<td align="right">State:</td>
<td><cfinput type="text" name="state"
value="#form.state#"></td>
</tr>
<tr>
<td align="right">Zip Code:</td>
<td><cfinput type="text" name="zip"
value="#form.zip#"></td>
</tr>
<tr>
<td align="right">Phone Number:</td>
<td><cfinput type="text" name="phone"
value="#form.phone#" maxlength="12"></td>
</tr>
<tr>
<td align="right">When did you enroll at Ivy Tech?:</td>
<td><cfinput type="text" name="enroll"
value="#form.enroll#"></td>
</tr>
<tr>
<td align="right">What is your plan of study?:</td>
<td><cfinput type="text" name="study"
value="#form.study#"></td>
</tr>
</table>
<table>
<tr>
<td>Would you like to:</td>
</tr>
<tr>
<td>
<cfinput type="checkbox" name="appointment"
value="appointment">Request an appointment with an advisor and get more
information?</td>
</tr>
<tr>
<td><cfinput type="checkbox" name="newsletter"
value="newsletter">Sign up to receive e-newsletters</td>
</tr>
<tr>
<td><cfinput type="submit" name="sendcomments"
value="Submit"></td>
</tr>
</table>
</cfform>
</cfoutput>
<cfelse>
<cfoutput>
<cfif isDefined ('form.appointment')>
<p>#form.Fname#, thank you for submitting your appointment request. An
advisor will contact you regarding this request shortly.</p>
<cfelseif isDefined ('form.newsletter')>
<p>#form.Fname#, thank you for requesting the Ivy-Tech E-Newsletter. You
will be added to its disctribution recipients.</p>
<cfelse><p>#form.Fname#, thank you for you contacting us. An advisor will
be in contact with you soon.</p></cfif>
</cfoutput>
</cfif>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3212
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15