Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!---If the http is not secure, make it secure--->
- <cfif not cgi.server_port_secure>
- <cflocation url="https://#cgi.server_name##cgi.script_name#?#cgi.query_string#" addtoken="no" />
- </cfif>
- <cfsilent>
- <!--- Param FORM variables. --->
- <cfparam name="URL.Reg" type="string" default="" />
- <cfparam name="FORM.fname" type="string" default="" />
- <cfparam name="FORM.lName" type="string" default="" />
- <cfparam name="FORM.uid" type="string" default="" />
- <cfparam name="FORM.classification" type="string" default="" />
- <cfparam name="FORM.school" type="string" default="" />
- <cfparam name="FORM.department" type="string" default="" />
- <cfparam name="FORM.address1" type="string" default="" />
- <cfparam name="FORM.address2" type="string" default="" />
- <cfparam name="FORM.email" type="string" default="" />
- <cfparam name="FORM.phone" type="string" default="" />
- <cfparam name="FORM.NOMfname" type="string" default="" />
- <cfparam name="FORM.NOMlname" type="string" default="" />
- <cfparam name="FORM.NOMuid" type="string" default="" />
- <cfparam name="FORM.NOMschool" type="string" default="" />
- <cfparam name="FORM.NOMdepartment" type="string" default="" />
- <cfparam name="FORM.NOMaddress1" type="string" default="" />
- <cfparam name="FORM.NOMaddress2" type="string" default="" />
- <cfparam name="FORM.NOMemail" type="string" default="" />
- <cfparam name="FORM.NOMphone" type="string" default="" />
- <cfparam name="FORM.nominationLetter" type="string" default="" />
- <cfparam name="FORM.curriculumVita" type="string" default="" />
- <cfparam name="FORM.captcha" 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 nominee's first name. --->
- <cfif NOT Len( FORM.fname )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's first name."
- ) />
- </cfif>
- <!--- Validate nominee's last name. --->
- <cfif NOT Len( FORM.lname )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's last name."
- ) />
- </cfif>
- <!--- Validate nominee's university id. --->
- <cfif NOT Len( FORM.uid )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's ten digit University ID."
- ) />
- </cfif>
- <!---
- <!--- Validate nominee's classification. --->
- <cfif NOT Len( FORM.classification )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select nominee's classification."
- ) />
- </cfif>
- <!--- Validate nominee's school. --->
- <cfif NOT Len( FORM.school )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's school."
- ) />
- </cfif>
- <!--- Validate nominee's address. --->
- <cfif NOT Len( FORM.address1 )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's campus address."
- ) />
- </cfif>
- <!---Validate nominee's email--->
- <cfif not len(form.email) or not isValid("email", form.email)>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's University email address."
- ) />
- </cfif>
- <!---Validate nominee's phone--->
- <cfif not len(form.phone)>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominee's University phone number."
- ) />
- </cfif>
- <!--- Validate nominator's first name. --->
- <cfif NOT Len( FORM.NOMfname )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's first name."
- ) />
- </cfif>
- <!--- Validate nominator's last name. --->
- <cfif NOT Len( FORM.NOMlname )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's last name."
- ) />
- </cfif>
- <!--- Validate nominator's university id. --->
- <cfif NOT Len( FORM.NOMuid )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's ten digit University ID."
- ) />
- </cfif>
- <!--- Validate nominator's school. --->
- <cfif NOT Len( FORM.NOMschool )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's school."
- ) />
- </cfif>
- <!--- Validate nominator's address. --->
- <cfif NOT Len( FORM.NOMaddress1 )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's campus address."
- ) />
- </cfif>
- <!---Validate nominator's email--->
- <cfif not len(form.NOMemail) or not isValid("email", form.NOMemail)>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's University email address."
- ) />
- </cfif>
- <!---Validate nominator's phone--->
- <cfif not len(form.NOMphone)>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter nominator's University phone number."
- ) />
- </cfif>
- ---->
- <!---When it comes to validating the file upload, we want to check to see if they selected one. Then, once they selected one, we ONLY want to mess with it if there are no errors caused by other form fields.--->
- <cfif NOT Len( FORM.nominationLetter )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select a file to upload as the nomination letter."
- ) />
- </cfif>
- <cfif NOT Len( FORM.curriculumVita )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select a file to upload as the curriculum vita."
- ) />
- </cfif>
- <!---
- <cfif NOT Len( FORM.recommendation )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select a file to upload as recommendation letter ."
- ) />
- </cfif>
- --->
- <!---Validate CAPTCHA --->
- <cfif form.captcha neq session.captcha>
- <cfset ArrayAppend(
- arrErrors,
- "You did not enter the correct security text."
- ) />
- <cfelseif ArrayLen( arrErrors )>
- <!---The file has been selected, but there are errors caused by other parts of the form validation. Therefore, we now have a file that is just sitting in our temp folder. Delete this file to keep a clean server. --->
- <cftry>
- <cffile
- action="DELETE"
- file="#FORM.nominationLetter#"
- />
- <cfcatch>
- <!--- File delete error. --->
- </cfcatch>
- </cftry>
- <cftry>
- <cffile
- action="DELETE"
- file="#FORM.curriculumVita#"
- />
- <cfcatch>
- <!--- File delete error. --->
- </cfcatch>
- </cftry>
- <cfelse>
- <!---Set file upload destination path to nominationUploads/firstname_lastname--->
- <cfset destination = expandPath("./nominationUploads/#trim(fname)#_#trim(lname)#_#trim(uid)#/")>
- <!---If the destination directory does not exist, create it. This will be unique for each nominee.--->
- <cfif not directoryExists(destination)>
- <cfdirectory action="create" directory="#destination#">
- </cfif>
- <!---The docuement has been selected and there are no other errors caused by Form validation. Therefore, we can now deal with the file upload. There is a chance that the file upload will cause an error, so be sure to wrap all file actions in CFTry / CFCatch blocks.--->
- <cftry>
- <cffile
- action="UPLOAD"
- filefield="nominationLetter"
- destination="#destination#"
- nameconflict="MAKEUNIQUE"
- />
- <!---
- Now that we have the file uploaded, let's
- check the file extension. I find this to be
- better than checking the MIME type as that
- can be inaccurate (so can this, but at least
- it doesn't throw a ColdFusion error).
- --->
- <cfif NOT ListFindNoCase(
- "doc,docx,pdf,txt,rtf",
- CFFILE.ServerFileExt
- )>
- <cfset ArrayAppend(
- arrErrors,
- "Only doc, docx, pdf, txt, and rtf file formats are accepted as the nomination letter."
- ) />
- <!---
- Since this was not an acceptable file,
- let's delete the one that was uploaded.
- --->
- <cftry>
- <cffile
- action="DELETE"
- file="#destination##File.ServerFile#"
- <!---file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"--->
- />
- <cfcatch>
- <!--- File Delete Error. --->
- </cfcatch>
- </cftry>
- </cfif>
- <!--- Catch any file errors. --->
- <cfcatch>
- <!---
- There was some sort of error with the
- file upload. Set the error and then try
- to delete the file.
- --->
- <cfset ArrayAppend(
- arrErrors,
- "There was a problem uploading the nomination letter."
- ) />
- <!---
- Try to delete the file. Again, we want
- to use CFTry / CFCatch whenever dealing
- with files, especially if we don't know
- if the file is even at the given path.
- --->
- <cftry>
- <cffile
- action="DELETE"
- file="#destination##File.ServerFile#"
- <!---file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"--->
- />
- <cfcatch>
- <!--- File delete errors. --->
- </cfcatch>
- </cftry>
- </cfcatch>
- </cftry>
- <!---The docuement has been selected and there are no other errors caused by Form validation. Therefore, we can now deal with the file upload. There is a chance that the file upload will cause an error, so be sure to wrap all file actions in CFTry / CFCatch blocks.--->
- <cftry>
- <cffile
- action="UPLOAD"
- filefield="curriculumVita"
- destination="#destination#"
- nameconflict="MAKEUNIQUE"
- />
- <!---
- Now that we have the file uploaded, let's
- check the file extension. I find this to be
- better than checking the MIME type as that
- can be inaccurate (so can this, but at least
- it doesn't throw a ColdFusion error).
- --->
- <cfif NOT ListFindNoCase(
- "doc,docx,pdf,txt,rtf",
- CFFILE.ServerFileExt
- )>
- <cfset ArrayAppend(
- arrErrors,
- "Only doc, docx, pdf, txt, and rtf file formats are accepted as the curriculum vita."
- ) />
- <!---
- Since this was not an acceptable file,
- let's delete the one that was uploaded.
- --->
- <cftry>
- <cffile
- action="DELETE"
- file="#destination##File.ServerFile#"
- <!---file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"--->
- />
- <cfcatch>
- <!--- File Delete Error. --->
- </cfcatch>
- </cftry>
- </cfif>
- <!--- Catch any file errors. --->
- <cfcatch>
- <!---
- There was some sort of error with the
- file upload. Set the error and then try
- to delete the file.
- --->
- <cfset ArrayAppend(
- arrErrors,
- "There was a problem uploading the curriculum vita."
- ) />
- <!---
- Try to delete the file. Again, we want
- to use CFTry / CFCatch whenever dealing
- with files, especially if we don't know
- if the file is even at the given path.
- --->
- <cftry>
- <cffile
- action="DELETE"
- file="#destination##File.ServerFile#"
- <!---file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"--->
- />
- <cfcatch>
- <!--- File delete errors. --->
- </cfcatch>
- </cftry>
- </cfcatch>
- </cftry>
- </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 )>
- <!--- Create variable to reference the original document name and extension uploaded from client. --->
- <cfset clientNominationLetter = #file.ClientFile#>
- <!---Create variable to reference renamed document. Retain orignal file extension.--->
- <cfset renameNomination = "01_nominationLetter"&"."&#cffile.clientFileExt#>
- <!---Rename uploaded document using variable. Save renamed document to original destination.--->
- <cffile action="rename"
- source="#destination##File.ServerFile#"
- destination="#destination##Trim(renameNomination)#">
- <!--- Create variable to reference the original document name and extension uploaded from client.--->
- <cfset clientCurriculumVita = #file.ClientFile#>
- <!---Create variable to reference renamed document. Retain orignal file extension.--->
- <cfset renameCurriculumVita = "02_curriculumVita"&"."&#cffile.clientFileExt#>
- <!---Rename uploaded document using variable. Save renamed document to original destination.--->
- <cffile action="rename"
- source="#destination##File.ServerFile#"
- destination="#destination##Trim(renameCurriculumVita)#">
- <cfmail
- to="[email protected]"
- from="[email protected]"
- subject="Alvin S. Bynum Mentor Award"
- type="html"
- failto="[email protected]"
- >
- <p>Hello,</p>
- <p>
- The following nomination has been
- submitted through the <a href="#CGI.HTTP_REFERER#">Alvin S. Bynum Mentor Award web site</a> on
- #DateFormat( Now(), "mmm d, yyyy" )# at
- #TimeFormat( Now(), "h:mm TT" )#.
- </p>
- <h3>Nominee Details</h3>
- <ul>
- <li>First Name: #form.fname#</li>
- <li>Last Name: #form.lname#</li>
- </ul>
- <h3>Document Details</h3>
- <ul>
- <li>Nomination Letter: #clientNominationLetter#</li>
- <li>Curriculum Vita: #clientCurriculumVita#</li>
- </ul>
- <br />
- <p>Thank you,</p>
- <p>Academic Affairs<br />
- AO 126<br />
- 317.274.4627 phone<br />
- 317.278.0695 fax<br />
- <a href="http://academicaffairs.iupui.edu">http://academicaffairs.iupui.edu</a><br />
- </cfmail>
- <!---
- At this point, you would probably forward
- the user to another page using something
- like CFLocation.
- --->
- <cflocation url="#cgi.SCRIPT_NAME#?reg=y" addtoken="no">
- </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" />
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
- <script>
- $(document).ready(function() {
- $("#captchaDiv").load("showcaptcha.cfm");
- $("#reloadLink").click(function(e) {
- $("#captchaDiv").load("showcaptcha.cfm");
- e.preventDefault();
- });
- })
- </script>
- </head>
- <cfoutput>
- <!--- Check to see if we have any form errors. --->
- <cfif ArrayLen( arrErrors )>
- <p class="attention">
- Please review the following:
- </p>
- <ul class="attention">
- <cfloop
- index="intError"
- from="1"
- to="#ArrayLen( arrErrors )#"
- step="1">
- <li>
- #arrErrors[ intError ]#
- </li>
- </cfloop>
- </ul>
- </cfif>
- <cfif URL.Reg EQ "Y">
- <p class="attention">Thank you for submitting your profile information.</p>
- <cfelse>
- <form
- action="#cgi.SCRIPT_NAME#"
- method="post"
- enctype="multipart/form-data">
- <!--- Our form submission flag. --->
- <input type="hidden" name="submitted" value="1" />
- <p>Fields marked <span class="required">&##8727;</span> are required.</p>
- <fieldset>
- <legend>Nominee Information</legend>
- <div class="notes">
- <h4>Eligibility</h4>
- <p class="last">Those eligible include full- and part-time faculty and academic professional staff, including all advisors, mentors, and counselors at the TE, PA, and PB employee classifications.</p>
- </div>
- <ol>
- <li>
- <label for="first name"><span class="required">*</span>First Name:</label>
- <input name="fname" type="text" maxlength="25" value="#form.fname#"/>
- </li>
- <li>
- <label for="last name"><span class="required">*</span>Last Name:</label>
- <input name="lname" type="text" maxlength="25" value="#form.lname#" />
- </li>
- <li>
- <label for="university id"><span class="required">*</span>University ID:</label>
- <input name="uid" type="text" maxlength="10" value="#form.uid#"/>
- </li>
- <!---
- <li>
- <label for="classification"><span class="required">*</span>Classification:</label>
- <select name="classification" />
- <option value="">– select –</option>
- <option value="faculty"<cfif classification EQ "faculty"> selected="selected"</cfif>>Faculty (Full- or part-time)</option>
- <option value="staff" <cfif classification EQ "staff"> selected="selected"</cfif>>Professional Staff (TE, PA, or PB)</option>
- </select>
- </li>
- <br />
- <li>
- <label for="school"><span class="required">*</span>School:</label>
- <input name="school" type="text" maxlength="50" value="#form.school#" />
- </li>
- <li>
- <label for="department">Department:</label>
- <input name="department" type="text" maxlength="50" value="#form.department#" />
- </li>
- <li>
- <label for="address 1"><span class="required">*</span>Campus Address:</label>
- <input name="address1" type="text" maxlength="50" value="#form.address1#"/>
- </li>
- <li>
- <label for="address 2"> </label>
- <input name="address2" type="text" maxlength="50" value="#form.address2#" />
- </li>
- <li>
- <label for="email"><span class="required">*</span>University Email:</label>
- <input name="email" type="text" maxlength="20" value="#form.email#" />
- </li>
- <li>
- <label for="phone"><span class="required">*</span>University Phone Number:</label>
- <input name="phone" type="text" maxlength="20" value="#form.phone#" />
- </li>
- </ol>
- </fieldset>
- <fieldset class="nominator">
- <legend>Nominator Information</legend>
- <div class="notes">
- <h4>Nominator Information</h4>
- <p class="last">Please enter your information.</p>
- <p class="last"><br />
- For jointly prepared nominations, only one Nominator's information can be entered as a contact. All other Nominators can be accounted for at the end of the Nomination Letter.</p>
- </div>
- <ol>
- <li>
- <label for="NOMfname"><span class="required">*</span>First Name:</label>
- <input name="NOMfname" type="text" maxlength="25" value="#form.NOMfname#" />
- </li>
- <li>
- <label for="NOMlname"><span class="required">*</span>Last Name:</label>
- <input name="NOMlname" type="text" maxlength="25" value="#form.NOMlname#" />
- </li>
- <li>
- <label for="NOMuid"><span class="required">*</span>University ID:</label>
- <input name="NOMuid" type="text" maxlength="10" value="#form.NOMuid#" />
- </li>
- <li>
- <label for="NOMschool"><span class="required">*</span>School:</label>
- <input name="NOMschool" type="text" maxlength="50" value="#form.NOMschool#" />
- </li>
- <li>
- <label for="NOMdepartment">Department:</label>
- <input name="NOMdepartment" type="text" maxlength="50" value="#form.NOMdepartment#" />
- </li>
- <li>
- <label for="NOMaddress1"><span class="required">*</span>Campus Address:</label>
- <input name="NOMaddress1" type="text" maxlength="50" value="#form.NOMaddress1#" />
- </li>
- <li>
- <label for="NOMaddress2"> </label>
- <input name="NOMaddress2" type="text" maxlength="50" value="#form.NOMaddress2#" />
- </li>
- <li>
- <label for="NOMemail"><span class="required">*</span>University Email:</label>
- <input name="NOMemail" type="text" maxlength="20" value="#form.NOMemail#" />
- </li>
- <li>
- <label for="NOMphone"><span class="required">*</span>University Phone:</label>
- <input name="NOMphone" type="text" maxlength="20" value="#form.NOMphone#" />
- </li>
- --->
- </ol>
- </fieldset>
- <fieldset>
- <ol>
- <li>
- <label for="nomination-letter"><span class="required">*</span>Nomination Letter:</label>
- <input type="file" name="nominationLetter" />
- </li>
- <li>
- <label for="curriculum-vita"><span class="required">*</span>Curriculum Vita:</label>
- <input type="file" name="curriculumVita" />
- </li>
- <li>
- <label for="recommendation"><span class="required">*</span>Recommendation Letter 1:</label>
- <input type="file" name="recommendation" tabindex="22">
- </li>
- <li>
- <label for="security"><span class="required">*</span>Enter Text Below (case-sensitive):</label>
- <input id="captcha" name="captcha" type="text" />
- </li>
- <div id="captchaDiv"></div>
- Can't read? <a href="" id="reloadLink">Reload</a>
- </ol>
- </fieldset>
- <br />
- <input type="hidden" value="#Now()#" />
- <input type="submit" value="Submit" />
- </form>
- </cfif>
- </cfoutput>
- <div class="request"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment