Form Issues related to Salesforce
Out of context: Reply #2
- Started
- Last post
- 6 Responses
- ChickenCrab0
--------------------------------...
This is the first part of our existing form and goes above the opening html tag for processing.
--------------------------------...<!--- FORM PROCESSING --->
<!--- Add cfparams to prevent errors on the page --->
<cfparam name="FORM.Name" default="">
<cfparam name="FORM.Company" default="">
<cfparam name="FORM.Email" default="">
<cfparam name="FORM.Phone" default="">
<cfparam name="FORM.Products" default="">
<cfparam name="FORM.Comments" default="">
<!--- Set the length of the text string for the CAPTCHA image. --->
<cfset stringLength=6>
<!--- Specify the list of characters used for the random text string. The following list limits the confusion between upper- and lowercase letters as well as between numbers and letters. --->
<cfset stringList="2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z">
<cfset rndString="">
<!--- Create a loop that builds the string from the random characters. --->
<cfloop from="1" to="#stringLength#" index="i">
<cfset rndNum=RandRange(1,listLen(stringList))>
<cfset rndString=rndString & listGetAt(stringList,rndNum)>
</cfloop>
<!--- Hash the random string. --->
<cfset rndHash=Hash(rndString)>
<!--- Create an empty error string --->
<cfset strError = "">
<!--- Create an string to show the form and set it to true--->
<cfset showForm = "true">
<!--- If the form is submitted --->
<cfif isDefined("FORM.doForm") AND FORM.doForm EQ "true">
<!--- If the Name field is empty --->
<cfif Len(Trim(FORM.Name)) LT 1>
<!--- Add this to the error string --->
<cfset strError = strError & "Please enter your name.<br>">
</cfif>
<!--- If the Company field is empty --->
<cfif Len(Trim(FORM.Company)) LT 1>
<!--- Add this to the error string --->
<cfset strError = strError & "Please enter your company name.<br>">
</cfif>
<!--- If the Email field is empty --->
<cfif Len(Trim(FORM.Email)) LT 1>
<!--- Add this to the error string --->
<cfset strError = strError & "Please enter your email address.<br>">
</cfif>
<!--- If the Email field is not valid --->
<cfif IsValid("email", FORM.Email)>
<!--- Add this to the error string --->
<cfelse>
<cfset strError = strError & "Please check that the email address you entered is valid.<br>">
</cfif>
<!--- If the moreInformation text input is changed a robot is trying to SPAM --->
<cfif Trim(FORM.moreInformation) NEQ "More information here!">
<!--- Add this to the error string --->
<cfset strError = strError & "SPAM, SPAM, SPAM, SPAM!<br>">
</cfif>
<!--- If the CAPTCHA values are not equal --->
<cfif #FORM.hashVal# NEQ Hash(#FORM.capText#)>
<!--- Add this to the error string --->
<cfset strError = strError & "The captcha text does not match the image. Please check it again and remember that it is case sensitive.<br>">
</cfif>
<!--- If the error string is still empty --->
<cfif strError EQ "">
<!--- Set showForm as false --->
<cfset showForm = "false">
<!--- Send the email --->
<cfmail
cc=""
replyto="#FORM.Email#"
subject="GM - Contact Us"
server="mail.companyname.com">
NAME: #Trim(FORM.Name)#
COMPANY: #Trim(FORM.Company)#
EMAIL: #Trim(FORM.Email)#
PHONE: #Trim(FORM.Phone)#
INTERESTED IN: #Trim(FORM.Products)#
COMMENTS: #Trim(FORM.Comments)#
</cfmail>
</cfif>
</cfif>
<!--- END FORM PROCESSING --->