Question
Stupid Noob Question About Form Validation
I can't get this code to work. Can some kind-hearted soul
look at it and tell me what stupid thing I'm doing wrong? It
processes the output of a contact or email form. The field "status"
is indeed defined on the form as a hidden field. When I enter
appropriate text in the fields of the form, it takes me to
"error.cfm" every time. Here's what I'm entering in the form for
testing purposes:
fromemail = crazy@windmills.com
yourname = Jack
phone = 407-755-0757
message = Message
Here's the code that processes the form output:
<cfset emailIndex = FindOneOf("@aeiou", form.fromemail)>
<cfset nameIndex = FindOneOf("aeiou", form.yourname)>
<cfset phoneIndex = FindOneOf("123456789",form.phone)>
<cfset messageIndex = FindOneOf("aeiou",form.message)>
<!--- Check to see if the form was submitted. Also check for valid data in each form field. --->
<cfif isDefined("form.status") AND form.status eq "sendemail" AND emailIndex GT 1 AND nameIndex GT 1 AND phoneIndex GT 1 AND messageIndex GT 1>
<!--- If the form was submitted, send the email! --->
<!-- NOTE: Hosting company email security requires that the username, password, and server name be included in the ColdFusion code. -->
<cfmail to="someone@domain.com"
from="someone@domain.com"
username="someone@domain.com"
password="correct_password_verified"
server="correct_server_verified"
replyto="#form.fromemail#"
subject="Email From website"
failto="validEmail@domain.com">
This message is from: #Form.yourname#, #form.fromemail#, #form.phone#
#FORM.message#
</cfmail>
<cflocation url="success.cfm">
<cfelse>
<cflocation url="error.cfm">
</cfif>
The form is located at http://www.GwenHarrison.com/contact/contactme.cfm.
fromemail = crazy@windmills.com
yourname = Jack
phone = 407-755-0757
message = Message
Here's the code that processes the form output:
<cfset emailIndex = FindOneOf("@aeiou", form.fromemail)>
<cfset nameIndex = FindOneOf("aeiou", form.yourname)>
<cfset phoneIndex = FindOneOf("123456789",form.phone)>
<cfset messageIndex = FindOneOf("aeiou",form.message)>
<!--- Check to see if the form was submitted. Also check for valid data in each form field. --->
<cfif isDefined("form.status") AND form.status eq "sendemail" AND emailIndex GT 1 AND nameIndex GT 1 AND phoneIndex GT 1 AND messageIndex GT 1>
<!--- If the form was submitted, send the email! --->
<!-- NOTE: Hosting company email security requires that the username, password, and server name be included in the ColdFusion code. -->
<cfmail to="someone@domain.com"
from="someone@domain.com"
username="someone@domain.com"
password="correct_password_verified"
server="correct_server_verified"
replyto="#form.fromemail#"
subject="Email From website"
failto="validEmail@domain.com">
This message is from: #Form.yourname#, #form.fromemail#, #form.phone#
#FORM.message#
</cfmail>
<cflocation url="success.cfm">
<cfelse>
<cflocation url="error.cfm">
</cfif>
The form is located at http://www.GwenHarrison.com/contact/contactme.cfm.