1. <!---Added to prevent an error if check box is empty--->
  2. <cfparam name="FORM.allst" default="">
  3. <cfparam name="FORM.all" default="no">
  4. <cfparam name="FORM.toAddress" default="">
  5. <cfparam name="FORM.subject" default="Request A Quote For Mailing List">
  6. <cfparam name="FORM.messageBody" default="">
  7.  
  8. <!---Get all US states that are active--->
  9. <cfquery name="allStates" datasource="#request.dsn#" username="#request.un#" password="#request.pw#">
  10. SELECT statename
  11. FROM states
  12. WHERE IsActive = 1
  13. AND CountryID = 1
  14. </cfquery>
  15. <div class='featurebox_left'>
  16.  
  17. <!---Added captcha test here--->
  18.  
  19. <cffunction name="makeRandomString" returnType="string" output="false">
  20. <cfset var chars = "23456789ABCDEFHJKMNPRS">
  21. <cfset var length = randRange(2,4)>
  22. <cfset var result = "">
  23. <cfset var i = "">
  24. <cfset var char = "">
  25.  
  26. <cfscript>
  27. for(i=1; i <= length; i++) {
  28. char = mid(chars, randRange(1, len(chars)),1);
  29. result&=char;
  30. }
  31. </cfscript>
  32.  
  33. <cfreturn result>
  34. </cffunction>
  35.  
  36. <cfset showForm = true>
  37.  
  38. <cfparam name="form.captcha" default="">
  39. <cfparam name="form.captchaHash" default="">
  40.  
  41. <cfif isDefined("form.send")>
  42. <cfset errors = "">
  43.  
  44. <cfif hash(ucase(form.captcha)) neq form.captchaHash>
  45. <cfset errors = errors & "You Did Not Enter The Right Text Below.">
  46. </cfif>
  47.  
  48. <cfif errors is "">
  49. <!--- do something here --->
  50. <cfset showForm = false>
  51. </cfif>
  52.  
  53. </cfif>
  54.  
  55. <cfif showForm>
  56.  
  57. <cfset captcha = makeRandomString()>
  58. <cfset captchaHash = hash(captcha)>
  59. <cfoutput>
  60. <!---End captcha test--->
  61. <!--- Provide simple form for recipient and message --->
  62.  
  63. <cfform action="#cgi.script_name#" method="post">
  64.  
  65. <table width="100%" border="0" align="center" cellpadding="2"cellspacing="2">
  66. <!--- Table row: Input for Email Address --->
  67. <tr>
  68. <td>&nbsp;</td>
  69. <td>
  70. <!--- Display Error Message--->
  71. <cfif isDefined("errors")>
  72. <img src="graphics/warning.png" hspace="5" vspace="5" align="absmiddle" /><strong>#errors#</strong>
  73. </cfif></td>
  74. </tr>
  75. <tr>
  76. <th valign="top">Email:</th>
  77. <td>
  78. <cfinput type="text"
  79. name="toAddress"
  80. value="#FORM.toAddress#"
  81. message="You must provide an email address (example@gmail.com)"
  82. validateat="onSubmit,onServer"
  83. validate="email"
  84. required="yes"
  85. size="50"> </td>
  86. </tr>
  87.  
  88. <!--- Table row: Input for E-mail Subject --->
  89. <tr>
  90. <th valign="top">Subject:</th>
  91. <td>
  92. <cfinput type="text"
  93. name="subject"
  94. value="#FORM.subject#"
  95. required="yes"
  96. size="50" maxlength="100"
  97. message="You must provide a subject for the email. (Maximum 100 characters)"> </td>
  98. </tr>
  99.  
  100. <!--- Table row: Input for actual Message Text --->
  101. <tr>
  102. <th valign="top">Your Message:</th>
  103. <td>
  104. <cftextarea name="messageBody"
  105. cols="50"
  106. rows="5"
  107. wrap="hard"
  108. required="yes"
  109. value="#form.messageBody#"
  110. maxlength="1000"
  111. message="You must provide a message body. (Maximum 1000 characters)" /> </td>
  112. </tr>
  113. <!---Table row: check box for all states --->
  114. <tr>
  115. <td><!---Howdy #session.name#---></td>
  116. <td valign="top">
  117.  
  118. <!---<cfinput type="checkbox" name="all" checked="no"> All 50 States--->
  119. <cfinput type="checkbox"
  120. name="all"
  121. checked="#form.all#"> All 50 States
  122.  
  123. </td>
  124. </tr>
  125. <tr>
  126. <td>&nbsp;</td>
  127. <td>
  128. <cfloop query="allstates">
  129. <input type="checkbox" name="allst" value="#statename#"> #statename#<br />
  130. </cfloop>
  131. </td>
  132. </tr>
  133. <!--- Table row: Input for captcha text --->
  134. <tr>
  135. <td valign="top">&nbsp;</td>
  136. <td>Enter Text Below:&nbsp;
  137. <cfinput type="text"
  138. name="captcha"
  139. required="yes"
  140. size="10"
  141. message="Please type the letters and numbers below.">
  142. </td>
  143. </tr>
  144. <!--- Table row: Display Captcha Image --->
  145. <tr>
  146. <td>&nbsp;</td>
  147. <td>
  148. <cfimage action="captcha" width="300" height="75" text="#captcha#">
  149. <cfinput type="hidden"
  150. name="captchaHash"
  151. value="#captchaHash#"> </td>
  152. </tr>
  153. <!--- Table row: Submit button to send message --->
  154. <tr>
  155. <td valign="top">&nbsp;</td>
  156. <td>
  157. <cfinput type="submit"
  158. name="send"
  159. validate="submitonce"
  160. value="Send Message Now"> </td>
  161. </tr>
  162. <tr>
  163. <td colspan="2" valign="top">&nbsp;</td>
  164. </tr>
  165. </table>
  166. </cfform>
  167. </cfoutput>
  168.  
  169. <cfelse>
  170. <!---Go to here if captcha is correct--->
  171.  
  172. <!--- We do not want ColdFusion to suppress whitespace here --->
  173. <cfprocessingdirective suppressWhitespace="No">
  174.  
  175. <!--- Send the mail message, based on form input --->
  176. <cfmail
  177. subject="#FORM.subject#" type="html"
  178. from='#FORM.toAddress#'
  179. to="webmaster@firefightingnews.com"
  180. bcc="mcconaghey@vzw.blackberry.net"
  181. replyto="#FORM.toAddress#"
  182. >
  183. <b>This is a message from request a quote from our fire department mailing list page on FireFightingNews.com:</b>
  184. <p></p>
  185. #FORM.messageBody#
  186. <p></p>
  187. #FORM.all#
  188. <p></p>
  189. #FORM.allst#
  190. <br />
  191. </cfmail>
  192.  
  193. </cfprocessingdirective>
  194.  
  195. <!--- Display "success" message to user --->
  196. <cfinclude template="email_ok.cfm">
  197.  
  198. </cfif>
  199. </div>