Advertisement
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=""
- />
- <!---
- 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 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="me@email.com"
- from="no-reply@email.com"
- subject="Civic Engagement Showcase"
- type="html"
- failto="fail@email.com"
- >
- <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="index.cfm?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#"
- method="post"
- enctype="multipart/form-data">
- <!--- Our form submission flag. --->
- <input type="hidden" name="submitted" value="1" />
- <h3>Civic Engagement Showcase </h3>
- <p>Fields marked <span class="required">&##8727;</span> are required.</p>
- <fieldset>
- <ol>
- <li>Affiliation:
- <select id="affiliation">
- <option value="">- Select Affiliation -</option>
- <!---<option value="status">Faculty or Staff</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">Sam H. Jones Scholar</option>
- <option value="partner">Community Partner</option>
- <option value="other">Other</option>
- </select>
- <br />
- <label id="status" for="affiliation"><span class="required">&##8727;</span>Enter School or Department
- <input type="text" id="status" value="#form.status#"/>
- </label>
- <label id="plater" for="plater">Enter Your Major
- <input type="text" id="plater" />
- </label>
- <label id="plater2" for="plater2">Select Number of Guests
- <SELECT id="guests">
- <option value="">- select guests -</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- </SELECT>
- </label>
- <label id="plater3" for="plater3">Guest Name:<input type="text" id="plater3" /></label>
- <label id="plater4" for="plater4">Guest Name:<input type="text" id="plater4" /></label>
- <label id="plater5" for="plater5">Guest Name:<input type="text" id="plater5" /></label>
- <label id="plater6" for="plater6">Guest Name:<input type="text" id="plater6" /></label>
- <label id="plater7" for="plater7">Guest Name:<input type="text" id="plater7" /></label>
- <label id="jones" for="jones">Enter Major
- <input type="text" id="jones" />
- </label>
- <label id="jones2" for="jones2">Enter Scholarship Name
- <input type="text" id="jones2" />
- </label>
- <label id="partner" for="partner">Enter Organization Name
- <input type="text" id="partner" />
- </label>
- <label id="other" for="other">Other
- <input type="text" id="other" />
- </label>
- </li>
- <br />
- <br />
- <li>
- Phone Number:<input type="text" id="phone" name="phone" maxlength="14" value="#form.phone#">
- </li>
- <li>
- Session:
- <br>
- <input type="checkbox" name="session" value="Workshop/Panel" />CE Workshop/Panel Presentations (CE 305/CE309)<br />
- <input type="checkbox" name="session" value="Poster" />CE Poster Presentation (CE 450)<br />
- <input type="checkbox" name="session" value="Showcase" />CE Showcase Program (CE 450)<br />
- </li>
- <li>
- <label for="security"><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
Advertisement