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