Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfsilent>
- <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.firstname"
- type="string"
- default=""
- />
- <cfparam
- name="FORM.lastname"
- type="string"
- default=""
- />
- <cfparam
- name="FORM.email"
- type="string"
- default=""
- />
- <cfparam
- name="FORM.phone"
- type="string"
- default=""
- />
- <cfparam
- name="FORM.topic"
- type="string"
- default=""
- />
- <cfparam
- name="FORM.requestedTime"
- type="string"
- default=""
- />
- <cfparam
- name="FORM.alternateTime"
- 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 first name. --->
- <cfif NOT Len( FORM.firstname )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter your first name."
- ) />
- </cfif>
- <!--- Validate last name. --->
- <cfif NOT Len( FORM.lastname )>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter your last name."
- ) />
- </cfif>
- <!--- Validate email address. --->
- <cfif not len(trim(form.email)) or not isValid("email", form.email)>
- <cfset ArrayAppend(
- arrErrors,
- "Please enter your email address."
- ) />
- </cfif>
- <!---Validate CAPTCHA --->
- <cfif hash(form.captcha) neq form.captchaHash>
- <cfset ArrayAppend(
- arrErrors,
- "You did not enter the right 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="myemail"
- cc="#form.email#"
- from="myemail"
- subject="Online Consultation Request Form"
- type="html"
- failto="myemail"
- >
- <p>Hello,</p>
- <p>
- The following application has been
- submitted through the <a href="#CGI.HTTP_REFERER#">Online Consultation Request Form</a> on
- #DateFormat( Now(), "mmm d, yyyy" )# at
- #TimeFormat( Now(), "h:mm TT" )#.
- </p>
- <h3>Contact Details</h3>
- <ul>
- <li>First Name: #form.firstname#</li>
- <li>Last Name: #form.lastname#</li>
- <li>Email: #form.email#</li>
- <cfif len("form.phone") NEQ ""><li>Phone: #form.phone#</li></cfif>
- <cfif len("form.topic") NEQ ""><li>Topic: #form.topic#</li></cfif>
- <cfif len("form.requestedTime") NEQ ""><li>Requested Time: #form.requestedTime#</li></cfif>
- <cfif len("form.alternateTime") NEQ ""><li>Alternate Time: #form.alternateTime#</li></cfif>
- </ul>
- <br />
- <br />
- <br />
- <p>Thank you,<br />
- CLS Web</p>
- <!---
- At this point, you would probably forward
- the user to another page using something
- like CFLocation.
- --->
- </cfmail>
- <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>Consultations</title>
- <link rel="icon" href="http://www.iupui.edu/favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="http://www.iupui.edu/favicon.ico" type="image/x-icon" />
- <link href="../css/global.css" rel="stylesheet" type="text/css" />
- <link href="../css/menu5.css" rel="stylesheet" type="text/css" />
- <link href="../css/crossColumn.css" rel="stylesheet" type="text/css" />
- <script src="../expand.js" type="text/javascript"></script>
- <script type="text/javascript">
- </head>
- <body>
- <div id="header">
- <cfinclude template="/includes/Header.html">
- </div>
- <div id="holderWhite">
- <cfinclude template="/includes/Header.html">
- <div id="leftMainPage"> <h2>Consultations </h2>
- <cfinclude template="../includes/leftLinksConsults.htm">
- <!---
- <h2 class="relatedHeader">Related Resources
- </h2>
- <div class="supportRes">
- </div>
- <h2>Teaching Tips</h2>
- <cfinclude template="../includes/teachTip.htm">
- --->
- <h2>For More Information</h2>
- <div class="contact">
- <p>Contact</p>
- </div>
- </div>
- <div id="rightMainPage">
- <div id="overall">
- <img src="../images/consults.jpg" width="615" height="189" />
- <cfif URL.Reg EQ "Y">
- <p>Thank you for submitting your inquiry</p>
- <cfelse>
- <h1>Greeting</h1>
- <cfoutput>
- <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>
- <form
- action="#cgi.SCRIPT_NAME#"
- method="post"
- enctype="multipart/form-data">
- <!--- Our form submission flag. --->
- <input type="hidden" name="submitted" value="1" /> <table width="74%" border="0" cellpadding="2" cellspacing="2">
- <tr>
- <td width="32%"><div align="right">First Name:</div></td>
- <td width="68%"><label for="textfield"></label>
- <input type="text" name="firstName" value="#form.firstname#"/></td>
- </tr>
- <tr>
- <td><div align="right">Last Name:</div></td>
- <td><input type="text" name="lastName" value="#form.lastname#"/></td>
- </tr>
- <tr>
- <td><div align="right">Email:</div></td>
- <td><input type="text" name="email" value="#form.email#" /></td>
- </tr>
- <tr>
- <td><div align="right">Phone:</div></td>
- <td><input type="text" name="phone" value="#form.phone#"/></td>
- </tr>
- <tr>
- <td><div align="right">Topic/Comments:</div></td>
- <td><label for="textarea"></label>
- <textarea name="topic" cols="35" value="#form.topic#"></textarea></td>
- </tr>
- <tr>
- <td><div align="right">Requested Time: </div></td>
- <td><input type="text" name="requestedTime" value="#form.requestedTime#" /></td>
- </tr>
- <tr>
- <td><div align="right">Alternate Time: </div></td>
- <td><input type="text" name="alternateTime" value="#form.alternateTime#" /></td>
- </tr>
- <tr>
- <td><label for="Submit"></label><div align="center">Fill in the words below: </div></td>
- <td><label for="textfield"></label></td>
- </tr>
- <tr>
- <td><label for="security">Enter Text Below (case-sensitive):</label>
- <td><input id="captcha" name="captcha" class="text" type="text" tabindex="20"/></td>
- </tr>
- <tr>
- <cfset captcha = makeRandomString()>
- <cfset captchaHash = hash(captcha)>
- <td><input type="hidden" name="captchaHash" value="#captchaHash#"></td>
- <td><cfimage action="captcha" width="300" height="55" text="#captcha#" fonts="verdana,arial" > </td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="hidden" value="#Now()#" />
- <input type="submit" value="Submit Inquiry" tabindex="21"/>
- </td>
- </tr>
- </table>
- </form>
- </cfoutput>
- </cfif>
- </div>
- </div>
- <div class="clear"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment