Advertisement
Guest User

Untitled

a guest
Mar 9th, 2011
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <cfsilent>
  2.     <cfif isDefined ("url.firstname")>
  3.         <cfset firstname = #url.firstname#>
  4.     </cfif>
  5.     <cfif isDefined ("url.lastname")>
  6.         <cfset lastname = #url.lastname#>
  7.     </cfif>
  8.     <cfif isDefined ("url.email")>
  9.         <cfset email = #url.email#>
  10.     </cfif>
  11.  
  12.     <cffunction name="makeRandomString" returntype="string" output="false">
  13.        <cfset var chars = "23456789ABCDEFGHJKMNPQRS">
  14.        <cfset var length = randRange(4,6)>
  15.        <cfset var result = "">
  16.        <cfset var i = "">
  17.        <cfset var char = "">
  18.        
  19.        <cfscript>
  20.            for(i=1; i <= length; i++) {
  21.               char = mid(chars, randRange(1, len(chars)),1);
  22.               result&=char;
  23.            }
  24.        </cfscript>
  25.          
  26.        <cfreturn result>
  27.     </cffunction>
  28.    
  29.    
  30.     <!--- Param FORM variables. --->
  31.     <cfparam
  32.         name="URL.Reg"
  33.        type="string"
  34.        default=""
  35.        />
  36.    
  37.     <cfparam
  38.         name="FORM.affiliation"
  39.         type="string"
  40.         default=""
  41.         />
  42.  
  43.     <cfparam
  44.         name="FORM.status"
  45.         type="string"
  46.         default=""
  47.         />
  48.  
  49.     <cfparam
  50.         name="FORM.phone"
  51.         type="string"
  52.         default=""
  53.         />
  54.  
  55.     <cfparam
  56.         name="FORM.session"
  57.         type="string"
  58.         default=""
  59.         />
  60.  
  61.  
  62.     <!---
  63.         For the form submission flag, since we are asking
  64.         it to be of type numeric, we have to catch the
  65.         CFParam in case someone has hacked the HTML and
  66.         altered the value being sent (a non-numeric value
  67.         will throw a ColdFusion error).
  68.     --->
  69.     <cftry>
  70.         <cfparam
  71.             name="FORM.submitted"
  72.             type="numeric"
  73.             default="0"
  74.             />
  75.  
  76.         <!--- Catch CFParam data type errors. --->
  77.         <cfcatch>
  78.             <cfset FORM.submitted = 0 />
  79.         </cfcatch>
  80.     </cftry>
  81.  
  82.     <!--- Define an array to catch the form errors. --->
  83.     <cfset arrErrors = ArrayNew( 1 ) />
  84.  
  85.     <!--- Check to see if the form has been submitted. --->
  86.     <cfif FORM.submitted>
  87.  
  88.         <!---
  89.             Now that the form has been submitted, we need
  90.             to validate the data.
  91.         --->
  92.        
  93.         <!--- Validate affiliation. --->
  94.         <cfif NOT Len( FORM.affiliation )>
  95.             <cfset ArrayAppend(
  96.                 arrErrors,
  97.                 "Please specify your affiliation."
  98.                 ) />
  99.         </cfif>
  100.  
  101.                
  102.            
  103.         <!---Validate CAPTCHA --->
  104.         <cfif hash(form.captcha) neq form.captchaHash>
  105.             <cfset ArrayAppend(
  106.                arrErrors,
  107.                "You did not enter the correct security text."
  108.                ) />
  109.         </cfif>        
  110.        
  111.         <!---
  112.             Now that we have validated our form data, let's
  113.             check to see if there are any form validation
  114.             errors. Only if there are no errors do w want to
  115.             continue processing the data - otherwise, we want
  116.             to skip this next part and let the form re-render.
  117.         --->
  118.         <cfif NOT ArrayLen( arrErrors )>
  119.  
  120.        
  121.  
  122.             <cfmail
  123.                 to="me@email.com"
  124.                 from="no-reply@email.com"
  125.                 subject="Civic Engagement Showcase"
  126.                 type="html"
  127.                 failto="fail@email.com"
  128.                 >
  129.                 <p>Hello,</p>
  130.                 <p>
  131.                     The following was submitted through the <a href="#CGI.HTTP_REFERER#"> web page</a> on
  132.                     #DateFormat( Now(), "mmm d, yyyy" )# at
  133.                     #TimeFormat( Now(), "h:mm TT" )#.
  134.                 </p>
  135.                
  136.                 <ul>
  137.                     <li>First Name: #firstname#</li>
  138.                     <li>Last Name: #lastname#</li>
  139.                     <li>Affiliation:  #form.affiliation#
  140.                         <cfif Len(form.status)>
  141.                             <ul>
  142.                                 <li>School or Department:  #form.status#</li>
  143.                             </ul>
  144.                         </cfif>                
  145.                     </li>
  146.                     <li>Phone Number:  #form.phone#</li>
  147.                     <li>Session: #form.session#</li>               
  148.                 </ul>
  149.            
  150.              
  151.             </cfmail>
  152.             <!---
  153.                 At this point, you would probably forward
  154.                 the user to another page using something
  155.                 like CFLocation.
  156.             --->
  157.  
  158.        
  159.         <cflocation url="index.cfm?reg=y"> 
  160.  
  161.         </cfif>
  162.     </cfif>
  163.  
  164. </cfsilent>
  165.  
  166.  
  167. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  168. <html xmlns="http://www.w3.org/1999/xhtml">
  169. <head>
  170. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  171. <title>My Site</title>
  172. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
  173. <script src="../../assets/js/jquery.maskedInput-1.2.2.min.js" type="text/javascript"></script>
  174.  
  175. <script src="../../expand.js" type="text/javascript"></script>
  176.  
  177. <script type="text/javascript">
  178. jQuery(function($) {
  179.       $.mask.definitions['~']='[+-]';
  180.       $('#date').mask('99/99/9999');
  181.       $('#phone').mask('(999) 999-9999');
  182.    });
  183. </script>
  184.  
  185. <script type="text/javascript">
  186. $(function() {
  187.     //This hides all initial textboxes
  188.     $('label').hide();
  189.     $('#affiliation').change(function() {
  190.         //This saves some time by caching the jquery value
  191.         var val = $(this).val();
  192.         //this hides any boxes that the previous selection might have left open
  193.         $('label').hide();
  194.         //This just opens the ones we want based off the selection
  195.         switch (val) {
  196.         case 'status':
  197.             $('#status').show();
  198.             break;
  199.         case 'plater':
  200.             $('#plater').show();
  201.             $('#plater2').show();
  202.             $('#plater3').show();
  203.             $('#plater4').show();
  204.             $('#plater5').show();
  205.             $('#plater6').show();
  206.             $('#plater7').show();
  207.             break;
  208.         case 'jones':
  209.             $('#jones').show();
  210.             $('#jones2').show();
  211.             break;
  212.         case 'partner':
  213.             $('#partner').show();
  214.             break;
  215.         case 'other':
  216.             $('#other').show();
  217.             break;
  218.            
  219.         }
  220.     });
  221.    
  222. });
  223.  
  224. </script>
  225. <style>
  226. label{display:block;}
  227. </style>
  228. </head>
  229. <body>
  230.  
  231.  
  232.         <div id="overall">
  233.             <cfif URL.Reg EQ "Y">
  234.                 <p>Thank you for your submission.  We have received your information.</p>
  235.             <cfelse>
  236.                 <cfoutput>
  237.                     <!--- Check to see if we have any form errors. --->
  238.                     <cfif ArrayLen( arrErrors )>
  239.                
  240.                         <h4>Please review the following:</h4>
  241.                
  242.                         <ul>
  243.                             <cfloop
  244.                                 index="intError"
  245.                                 from="1"
  246.                                 to="#ArrayLen( arrErrors )#"
  247.                                 step="1">
  248.                
  249.                                 <li>
  250.                                     <div class="required">#arrErrors[ intError ]#</div>
  251.                                 </li>
  252.                             </cfloop>
  253.                         </ul>
  254.                     </cfif>
  255.                 </cfoutput>
  256.    
  257.                 <cfoutput>
  258.                     <form
  259.                         action="#cgi.SCRIPT_NAME#"
  260.                         method="post"
  261.                         enctype="multipart/form-data">
  262.                                      
  263.                  <!--- Our form submission flag. --->
  264.                  <input type="hidden" name="submitted" value="1" />
  265.                     <h3>Civic Engagement Showcase </h3>
  266.                       <p>Fields marked <span class="required">&##8727;</span> are required.</p>
  267.                         <fieldset>
  268.                             <ol>  
  269.                                     <li>Affiliation:
  270.                                     <select id="affiliation">
  271.                                         <option value="">- Select Affiliation -</option>
  272.                                         <!---<option value="status">Faculty or Staff</option>--->
  273.                                         <option value="status"<cfif Form.affiliation EQ 'status'> selected="selected"</cfif>>Faculty or Staff</option>
  274.                                         <option value="plater"<cfif form.affiliation EQ 'plater'> selected="selected"</cfif>>Plater Medallion</option>
  275.                                         <option value="jones">Sam H. Jones Scholar</option>
  276.                                         <option value="partner">Community Partner</option>
  277.                                         <option value="other">Other</option>
  278.                                     </select>
  279.                                     <br />
  280.                                     <label id="status" for="affiliation"><span class="required">&##8727;</span>Enter School or Department
  281.                                         <input type="text" id="status" value="#form.status#"/>
  282.                                     </label>
  283.                                     <label id="plater" for="plater">Enter Your Major
  284.                                         <input type="text" id="plater" />
  285.                                     </label>
  286.                                     <label id="plater2" for="plater2">Select Number of Guests
  287.                                         <SELECT id="guests">
  288.                                             <option value="">- select guests -</option>
  289.                                             <option value="1">1</option>
  290.                                             <option value="2">2</option>
  291.                                             <option value="3">3</option>
  292.                                             <option value="4">4</option>
  293.                                             <option value="5">5</option>
  294.                                         </SELECT>
  295.                                     </label>
  296.                                     <label id="plater3" for="plater3">Guest Name:<input type="text" id="plater3" /></label>
  297.                                     <label id="plater4" for="plater4">Guest Name:<input type="text" id="plater4" /></label>
  298.                                     <label id="plater5" for="plater5">Guest Name:<input type="text" id="plater5" /></label>
  299.                                     <label id="plater6" for="plater6">Guest Name:<input type="text" id="plater6" /></label>
  300.                                     <label id="plater7" for="plater7">Guest Name:<input type="text" id="plater7" /></label>
  301.                                        
  302.                                     <label id="jones" for="jones">Enter Major
  303.                                         <input type="text" id="jones" />
  304.                                     </label>
  305.                                     <label id="jones2" for="jones2">Enter Scholarship Name
  306.                                         <input type="text" id="jones2" />
  307.                                     </label>
  308.                                
  309.                                     <label id="partner" for="partner">Enter Organization Name
  310.                                         <input type="text" id="partner" />
  311.                                     </label>
  312.                                     <label id="other" for="other">Other
  313.                                         <input type="text" id="other" />
  314.                                     </label>
  315.                                 </li>
  316.                                 <br />
  317.                                 <br />
  318.                                 <li>
  319.                                     Phone Number:<input type="text" id="phone" name="phone" maxlength="14" value="#form.phone#">
  320.                                 </li>
  321.                                 <li>
  322.                                     Session:
  323.                                         <br>
  324.                                         <input type="checkbox" name="session" value="Workshop/Panel" />CE Workshop/Panel Presentations (CE 305/CE309)<br />
  325.                                         <input type="checkbox" name="session" value="Poster" />CE Poster Presentation (CE 450)<br />
  326.                                         <input type="checkbox" name="session" value="Showcase" />CE Showcase Program (CE 450)<br />
  327.                                    
  328.                                    
  329.                                 </li>
  330.                                  
  331.                                 <li>
  332.                                     <label for="security"><span class="required">&##8727;</span>Enter Text Below (case-sensitive):</label>
  333.                                     <input id="captcha" name="captcha" class="text" type="text"/>
  334.                                 </li>
  335.                             </ol>
  336.                                 <cfset captcha = makeRandomString()>
  337.                                 <cfset captchaHash = hash(captcha)>
  338.                                     <input type="hidden" name="captchaHash" value="#captchaHash#">  
  339.                                 <cfimage action="captcha" width="300" height="55" text="#captcha#" fonts="verdana,arial" >  
  340.                             </fieldset>            
  341.                         <br />
  342.                        
  343.                        
  344.  
  345.                         <cfif isDefined ("url.firstname")>
  346.                             <input type="hidden"  name="firstname" value="<cfoutput>#url.firstname#</cfoutput>">
  347.                         </cfif>
  348.                         <cfif isDefined ("url.lastname")>
  349.                             <input type="hidden"  name="lastname" value="<cfoutput>#url.lastname#</cfoutput>">
  350.                         </cfif>
  351.                         <cfif isDefined ("url.email")>
  352.                             <input type="hidden"  name="email" value="<cfoutput>#url.email#</cfoutput>">
  353.                         </cfif>
  354.                         <input type="hidden" value="#Now()#" />
  355.                         <input type="submit" value="Submit"/>
  356.                 </form>
  357.    
  358.         </cfoutput>
  359.         </cfif>
  360.        
  361.    
  362. </body>
  363. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement