Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfsilent>
- <cfif isDefined ("url.firstname")>
- <cfset firstname = #url.firstname#>
- </cfif>
- <cfif isDefined ("url.lastname")>
- <cfset lastname = #url.lastname#>
- </cfif>
- <cfif isDefined ("url.email")>
- <cfset email = #url.email#>
- </cfif>
- <cffunction name="makeRandomString" returntype="string" output="false">
- <cfset var chars = "23456789ABCDEFGHJKMNPQRS">
- <cfset var length = randRange(4,6)>
- <cfset var result = "">
- <cfset var i = "">
- <cfset var char = "">
- <cfscript>
- for(i=1; i <= length; i++) {
- char = mid(chars, randRange(1, len(chars)),1);
- result&=char;
- }
- </cfscript>
- <cfreturn result>
- </cffunction>
- <!--- Param FORM variables. --->
- <cfparam name="URL.Reg" type="string" default=""/>
- <cfparam name="FORM.affiliation" type="string" default=""/>
- <cfparam name="FORM.status" type="string" default=""/>
- <cfparam name="FORM.phone" type="string" default=""/>
- <cfparam name="FORM.session" type="string" default="" />
- <cfparam name="FORM.major" type="string" default="" />
- <cfparam name="FORM.guests" type="string" default="" />
- <cfparam name="FORM.plater3" type="string" default="" />
- <cfparam name="FORM.plater4" type="string" default="" />
- <cfparam name="FORM.plater5" type="string" default="" />
- <cfparam name="FORM.plater6" type="string" default="" />
- <cfparam name="FORM.plater7" type="string" default="" />
- <cfparam name="FORM.jones" type="string" default="" />
- <cfparam name="FORM.jones2" type="string" default="" />
- <cfparam name="FORM.partner" type="string" default="" />
- <cfparam name="FORM.other" type="string" default="" />
- <cfparam name="FORM.sessionSymposium" default="no" />
- <cfparam name="FORM.sessionPresentPoster" default="no" />
- <cfparam name="FORM.sessionAttendPoster" default="no" />
- <cfparam name="FORM.sessionShowcase" default="no" />
- <!---
- For the form submission flag, since we are asking
- it to be of type numeric, we have to catch the
- CFParam in case someone has hacked the HTML and
- altered the value being sent (a non-numeric value
- will throw a ColdFusion error).
- --->
- <cftry>
- <cfparam
- name="FORM.submitted"
- type="numeric"
- default="0"
- />
- <!--- Catch CFParam data type errors. --->
- <cfcatch>
- <cfset FORM.submitted = 0 />
- </cfcatch>
- </cftry>
- <!--- Define an array to catch the form errors. --->
- <cfset arrErrors = ArrayNew( 1 ) />
- <!--- Check to see if the form has been submitted. --->
- <cfif FORM.submitted>
- <!---
- Now that the form has been submitted, we need
- to validate the data.
- --->
- <!--- Validate affiliation. --->
- <cfif NOT Len( FORM.affiliation )>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify your affiliation."
- ) />
- </cfif>
- <!---Validate School or Department if affiliation choice is status --->
- <cfif form.affiliation eq 'status' and not len (form.status)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify your school or department."
- ) />
- </cfif>
- <!---Validate major if affiliation choice is plater--->
- <cfif form.affiliation eq 'plater' and not len (form.major)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify your major."
- ) />
- </cfif>
- <!---Validate guests if affiliation choice is plater--->
- <cfif form.affiliation eq 'plater' and not len (form.guests)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify how many guests will accompany you."
- ) />
- </cfif>
- <!---Validate guests if affiliation choice is plater--->
- <cfif form.affiliation eq 'plater' and len (form.guests) and not len (form.plater3)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify the guest name(s)."
- ) />
- </cfif>
- <!---Validate major if affiliation choice is jones--->
- <cfif form.affiliation eq 'jones' and not len(form.jones)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify your major."
- ) />
- </cfif>
- <!---Validate major if affiliation choice is jones--->
- <cfif form.affiliation eq 'jones' and not len(form.jones2)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify your scholarship name."
- ) />
- </cfif>
- <!---Validate organization name if affiliation choice is partner--->
- <cfif form.affiliation eq 'partner' and not len(form.partner)>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify your organization name."
- ) />
- </cfif>
- <!---Validate otherif affiliation choice is other--->
- <cfif form.affiliation eq 'other' and not len(form.other)>
- <cfset ArrayAppend(
- arrErrors,
- "Please clarify ''other.''"
- ) />
- </cfif>
- <!---Validate phone number--->
- <cfif not Len(form.phone)>
- <cfset ArrayAppend(
- arrErrors,
- "Please provide your phone number."
- ) />
- </cfif>
- <!---Validate session--->
- <cfif form.sessionSymposium NEQ 1 or form.sessionPresentPoster NEQ 1 or form.sessionAttendPoster NEQ 1 or form.sessionShowcase NEQ 1>
- <cfset ArrayAppend(
- arrErrors,
- "Please specify at least one session."
- ) />
- </cfif>
- <!---Validate CAPTCHA --->
- <cfif hash(form.captcha) neq form.captchaHash>
- <cfset ArrayAppend(
- arrErrors,
- "You did not enter the correct security text."
- ) />
- </cfif>
- <!---
- Now that we have validated our form data, let's
- check to see if there are any form validation
- errors. Only if there are no errors do w want to
- continue processing the data - otherwise, we want
- to skip this next part and let the form re-render.
- --->
- <cfif NOT ArrayLen( arrErrors )>
- <cfmail
- to="[email protected]"
- from="[email protected]"
- subject="Civic Engagement Showcase"
- type="html"
- failto="[email protected]"
- >
- <p>Hello,</p>
- <p>
- The following was submitted through the <a href="#CGI.HTTP_REFERER#"> web page</a> on
- #DateFormat( Now(), "mmm d, yyyy" )# at
- #TimeFormat( Now(), "h:mm TT" )#.
- </p>
- <ul>
- <li>First Name: #firstname#</li>
- <li>Last Name: #lastname#</li>
- <li>Affiliation: #form.affiliation#
- <cfif Len(form.status)>
- <ul>
- <li>School or Department: #form.status#</li>
- </ul>
- </cfif>
- </li>
- <li>Phone Number: #form.phone#</li>
- <li>Session: #form.session#</li>
- </ul>
- </cfmail>
- <!---
- At this point, you would probably forward
- the user to another page using something
- like CFLocation.
- --->
- <cflocation url="#cgi.SCRIPT_NAME#?reg=y">
- </cfif>
- </cfif>
- </cfsilent>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>My Site</title>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
- <script src="../../assets/js/jquery.maskedInput-1.2.2.min.js" type="text/javascript"></script>
- <script src="../../expand.js" type="text/javascript"></script>
- <script type="text/javascript">
- jQuery(function($) {
- $.mask.definitions['~']='[+-]';
- $('#date').mask('99/99/9999');
- $('#phone').mask('(999) 999-9999');
- });
- </script>
- <script type="text/javascript">
- $(function() {
- //This hides all initial textboxes
- $('label').hide();
- $('#affiliation').change(function() {
- //This saves some time by caching the jquery value
- var val = $(this).val();
- //this hides any boxes that the previous selection might have left open
- $('label').hide();
- //This just opens the ones we want based off the selection
- switch (val) {
- case 'status':
- $('#status').show();
- break;
- case 'plater':
- $('#plater').show();
- $('#plater2').show();
- $('#plater3').show();
- $('#plater4').show();
- $('#plater5').show();
- $('#plater6').show();
- $('#plater7').show();
- break;
- case 'jones':
- $('#jones').show();
- $('#jones2').show();
- break;
- case 'partner':
- $('#partner').show();
- break;
- case 'other':
- $('#other').show();
- break;
- }
- });
- });
- </script>
- <style>
- label{display:block;}
- </style>
- </head>
- <body>
- <div id="overall">
- <cfif URL.Reg EQ "Y">
- <p>Thank you for your submission. We have received your information.</p>
- <cfelse>
- <cfoutput>
- <!--- Check to see if we have any form errors. --->
- <cfif ArrayLen( arrErrors )>
- <h4>Please review the following:</h4>
- <ul>
- <cfloop
- index="intError"
- from="1"
- to="#ArrayLen( arrErrors )#"
- step="1">
- <li>
- <div class="required">#arrErrors[ intError ]#</div>
- </li>
- </cfloop>
- </ul>
- </cfif>
- </cfoutput>
- <cfoutput>
- <form
- action="#cgi.SCRIPT_NAME#?firstname=#firstname#&lastname=#lastname#&email=#email#"
- method="post"
- enctype="multipart/form-data">
- <!--- Our form submission flag. --->
- <input type="hidden" name="submitted" value="1" />
- <h3>7<sup>th</sup> Annual Civic Engagement Showcase </h3>
- <p>Please fill out this page and click submit to complete registration. For more information, <a href="mailto:[email protected]">contact Mansi Patel</a>.</p>
- <p>Fields marked <span class="required">&##8727;</span> are required.</p>
- <fieldset>
- <ol>
- <li><span class="required">&##8727;</span>Affiliation:
- <select name="affiliation" id="affiliation">
- <option value="">- Select Affiliation -</option>
- <option value="status"<cfif Form.affiliation EQ 'status'> selected="selected"</cfif>>Faculty or Staff</option>
- <option value="plater"<cfif form.affiliation eq 'plater'> selected="selected"</cfif>>Plater Medallion</option>
- <option value="jones"<cfif form.affiliation eq 'jones'> selected="selected"</cfif>>Sam H. Jones Scholar</option>
- <option value="partner"<cfif form.affiliation eq 'partner'> selected="selected"</cfif>>Community Partner</option>
- <option value="other"<cfif form.affiliation eq 'other'> selected="selected"</cfif>>Other</option>
- </select>
- <br />
- <label id="status" for="affiliation"><span class="required">&##8727;</span>Enter School or Department
- <input type="text" id="status" name="status" value="#form.status#"/>
- </label>
- <label id="plater" for="plater"><span class="required">&##8727;</span>Enter Your Major
- <input type="text" name="major" id="plater" value="#form.major#"/>
- </label>
- <label id="plater2" for="plater2">Select Number of Guests
- <SELECT name="guests" id="guests">
- <option value="">- Select Guests -</option>
- <option value="1"<cfif form.guests EQ 1> selected="selected"></cfif>>1</option>
- <option value="2"<cfif form.guests EQ 2> selected="selected"></cfif>>2</option>
- <option value="3"<cfif form.guests EQ 3> selected="selected"></cfif>>3</option>
- <option value="4"<cfif form.guests EQ 4> selected="selected"></cfif>>4</option>
- <option value="5"<cfif form.guests EQ 5> selected="selected"></cfif>>5</option>
- </SELECT>
- </label>
- <label id="plater3" for="plater3">Guest Name:<input type="text" id="plater3" name="plater3" value="#form.plater3#"/></label>
- <label id="plater4" for="plater4">Guest Name:<input type="text" id="plater4" name="plater4" value="#form.plater4#"/></label>
- <label id="plater5" for="plater5">Guest Name:<input type="text" id="plater5" name="plater5" value="#form.plater5#"/></label>
- <label id="plater6" for="plater6">Guest Name:<input type="text" id="plater6" name="plater6" value="#form.plater6#"/></label>
- <label id="plater7" for="plater7">Guest Name:<input type="text" id="plater7" name="plater7" value="#form.plater7#" /></label>
- <label id="jones" for="jones"><span class="required">&##8727;</span>Enter Major
- <input type="text" id="jones" name="jones" value="#form.jones#"/>
- </label>
- <label id="jones2" for="jones2"><span class="required">&##8727;</span>Enter Scholarship Name
- <input type="text" id="jones2" name="jones2" value="#form.jones2#"/>
- </label>
- <label id="partner" for="partner"><span class="required">&##8727;</span>Enter Organization Name
- <input type="text" id="partner" name="partner" value="#form.partner#"/>
- </label>
- <label id="other" for="other"><span class="required">&##8727;</span>Other
- <input type="text" id="other" name="other" value="#form.other#"/>
- </label>
- </li>
- <br />
- <br />
- <li>
- <span class="required">&##8727;</span>Phone Number:<input type="text" id="phone" name="phone" maxlength="14" value="#form.phone#">
- </li>
- <li>
- Select one or more session(s):
- <br>
- <input type="checkbox" name="sessionSymposium" value="Symposium" <cfif isDefined("form.sessionSymposium") and form.sessionSymposium EQ '1'>checked="checked"</cfif> />Attend CE Symposium: 3:30-4:15 pm (CE 305/CE309)<br />
- <input type="checkbox" name="sessionPresentPoster" value="presentPoster" <cfif isDefined("form.sessionPresentPoster") and form.sessionPresentPoster EQ '1'>checked="checked"</cfif> />Present Poster Presentation: for applications, visit CSL Conference Page<br />
- <input type="checkbox" name="sessionAttendPoster" value="attendPoster" <cfif isDefined("form.sessionAttendPoster") and form.sessionAttendPoster EQ '1'>checked="checked"</cfif>/>Attend CE Poster Presentations: 4:00-4:45 pm and 5:45-6:30 pm (CE 450)<br />
- <input type="checkbox" name="sessionShowcase" value="Showcase" <cfif isDefined("form.sessionShowcase") and form.sessionShowcase EQ '1'>checked="checked"</cfif>/>Attend CE Showcase Program: 4:45-6:30 pm (CE 450)<br />
- </li>
- <li>
- <span class="required">&##8727;</span>Enter Text Below (case-sensitive):</label>
- <input id="captcha" name="captcha" class="text" type="text"/>
- </li>
- </ol>
- <cfset captcha = makeRandomString()>
- <cfset captchaHash = hash(captcha)>
- <input type="hidden" name="captchaHash" value="#captchaHash#">
- <cfimage action="captcha" width="300" height="55" text="#captcha#" fonts="verdana,arial" >
- </fieldset>
- <br />
- <cfif isDefined ("url.firstname")>
- <input type="hidden" name="firstname" value="<cfoutput>#url.firstname#</cfoutput>">
- </cfif>
- <cfif isDefined ("url.lastname")>
- <input type="hidden" name="lastname" value="<cfoutput>#url.lastname#</cfoutput>">
- </cfif>
- <cfif isDefined ("url.email")>
- <input type="hidden" name="email" value="<cfoutput>#url.email#</cfoutput>">
- </cfif>
- <input type="hidden" value="#Now()#" />
- <input type="submit" value="Submit"/>
- </form>
- </cfoutput>
- </cfif>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment