Thanks to all who attended my first CF Meetup presentation.

Info: http://www.meetup.com/coldfusionmeetup/calendar/11596049/?a=nr1p_grp&rv=nr1p

Recording: http://www.meetup.com/coldfusionmeetup/pages/Recordings_of_the_ColdFusion_Meetup-2009/

Demo Page (as seen in the presentation): http://www.gowestwebdesign.com/demos/contact-form/index.cfm

As far as I can tell we had a good turnout, and though talking to a silent connection takes some getting used to, the live-chat comments and interaction during the talk really made it fun (and helped me fill the full time slot with this simple subject!).

I really enjoy meeting other developers and designers, and I hope anybody who attended, had questions or just wants to get more involved in the community will drop me an email, check out our web developer newsgroups (see the link top right of this blog), and of course... be my Facebook and/or Twitter friend.

Thanks also to Charlie Arehart for all of his efforts keeping the CF Meetups going, and growing strong. He was the perfect balance of aggressive and encouraging in getting me to present this topic, and I am very glad he persisted. He's definitely the right guy for the positing of CF Host and quickly removed any concerns or worries I might have had just before we went live.

Now that it is done, I would like to do another! On that note, if there is anything you think I know about, that you'd like to see me share, please do drop me a line.

Several people asked to have a copy of the code used in the presentation. The sample below is directly from the file shown in the demo.

view plain print about
1<!--- START PROCESSING --->
2<cfif isDefined('form.senderFrom')>
3
4<!--- VALIDATE FIELDS --->
5
6<!--- check email --->
7<cfif NOT len(trim(form.senderFrom)) gt 6 or NOT isValid('email',form.senderFrom)>
8<cfset request.formError = 'A valid email address must be provided'>
9
10<!--- message --->
11<cfelseif NOT len(trim(form.senderMessage))>
12<cfset request.formError = 'Be sure to include a message'>
13
14<!--- honeypot --->
15<cfelseif len(trim(form.email_address))>
16<cfset request.formError = 'Spam!! <br />(Run away! Run away!)'>

17</cfif>
18
19<!--- /end VALIDATE FIELDS --->
20
21<!--- CHECK FOR UNWANTED CONTENT--->
22<!--- loop all form variables --->
23<cfloop index="f" list="#form.fieldnames#">
24<!--- set variable for field value --->
25<cfset value="#evaluate('form.#f#')#">
26
27<!--- BANNED WORDS --->
28<cfset bannedWordsList = "herring,albatross,dragon,grail,lumberjack">
29
30<!--- loop the banned words list and see if we have a match --->
31<!--- Check for banned words --->
32<cfloop list="#bannedWordsList#" delimiters="," index="w">
33<cfif FindNoCase(w,value)>
34
35<cfset request.formerror="<br />Beg your pardon? <br />Your WHAT hurts?">
36<cfbreak>
37</cfif>
38</cfloop>
39<!--- / end BANNED WORDS --->
40
41<!--- HTML BLOCK --->
42<cfset leftChar = '<' >
43<cfset rightChar = '>' >
44<!--- look for both characters contained in our content --->
45<cfif findNoCase(leftChar, value) AND findNoCase(rightChar, value)>
46<cfset request.formerror = "Text only please - no HTML">
47<cfbreak>
48</cfif>
49<!--- / end HTML BLOCK --->
50
51</cfloop>
52<!--- / end CHECK FOR UNWANTED CONTENT --->
53
54<fieldset>
55    <legend>
56        <cfif isDefined('request.formerror') and len(trim(request.formerror))>
57        Error!
58            <cfelse>
59        Thank You
60        </cfif>
61    </legend>
62
63<!--- SHOW RESPONSE --->
64<cfif isDefined('request.formerror') and len(trim(request.formerror))>
65<p><strong>ERROR: <cfoutput>#request.formerror#</cfoutput></strong></p>
66<p>Go <a href="javascript:history.back()">back</a> and try again</p>
67
68<cfelse>
69<p>Thank you. <br /><br />Your message has been sent and we will reply soon!</p>
70</cfif>
71<p>&nbsp;</p>
72<p>&nbsp;</p>
73<p>&nbsp;</p>
74<p>&nbsp;</p>
75<p>&nbsp;</p>
76</fieldset>
77
78<!--- IF FORM NOT SUBMITTED (show the form) --->
79<cfelse>
80
81<fieldset><legend>Sample Contact Form</legend>
82
83<cfform name="contactForm" action="#cgi.SCRIPT_NAME#" method="post">
84<div>
85<label for="senderName">Name:&nbsp;&nbsp;</label><cfinput type="text" name="senderName" size="48" value="" required="true" message="Your Name is required">
86</div>
87<div>
88<label for="senderFrom">Email:&nbsp;&nbsp;</label><cfinput type="text" name="senderFrom" size="48" value="" required="true" validate="email" message="Email Address is required">
89</div>
90<div>
91<label for="senderPhone">Phone:&nbsp;&nbsp;</label><input type="text" name="senderPhone" size="20" value="">
92</div>
93<div>
94<label for="senderPhone">Your Message:</label><textarea name="senderMessage" cols="30" rows="12" style="width:310px;"></textarea>
95</div>
96<div style="text-align:center">
97<input type="submit" value="Submit">
98</div>
99
100<div id="email_wrapper">
101<input type="text" name="email_address" value="" size="20">
102</div>
103
104</cfform>
105
106</fieldset>
107
108</cfif>
109<!--- / end IF FORM SUBMITTED --->

Thanks again to Charlie and everyone else - this has been a very positive and rewarding experience, and I hope to return with more good CF-Stuff to share.