please take a look at some of these code snippets i've taken from what i'm currently working on in CFMX 6.1. i'll explain briefly the context and purpose for each. i apologize if this is 'too verbose'.
*
<cfset qone = "First Name:">
<cfset qtwo = "Last Name:">
<cfset qthree = "Choose a Password:">
<cfset qfour = "Valid e-mail (post grad):">
** this sets the variables for an output later (see next snippet) to indicate which form fields were empty on posting **
<font color="MAROON">
<cfif isdefined("FORM.op")> // <!--- FORM HAS BEEN SUBMITTED --->
<cfset variables.emptymsg = "<ul>">
<cfif FORM.name_first EQ ""> // <!--- IF THE FIRST FIELD HOLDS A VALUE THEN... --->
<cfset variables.emptymsg = variables.emptymsg & "<li>#VARIABLES.qone#</li>">
<cfset variables.resub = 1>
<cfelse>
// <!--- <cfset variables.name_first = #Form.name_first#> --->
</cfif>
<cfif FORM.name_last EQ "">
<cfset variables.emptymsg = variables.emptymsg & "<li>#VARIABLES.qtwo#</li>">
<cfset variables.resub = variables.resub + 1>
<cfelse>
// <!--- <cfset variables.last = #Form.name_last#> --->
</cfif>
** here is my attempt at form validation -- the form posts back to the same page-- although i'm not currently using getcurrenttemplatepath() because it gives me a C:\folder\file.cfm string instead of *http://localhost/file.cfm*
** as you can see, variables.emptymsg (2nd line above) is established so it can be used to report the missing form fields
** variables.emptymsg concatenated on each field until form end, ultimately creating a UL for output indicating all empty fields this submission.
** variables.resub is a simple counter (in php, i'd use X++). is there an easier way?
// <!--- CREATE CFSWITCH HERE FOR VARIABLES.CORDIAL --->
<cfif isdefined("variables.resub")> // <!--- RESUB IS THE NUMERIC COUNTER --->
<cfswitch expression="#variables.resub#"> // <!--- WE ARE TESTING AGAINST THIS VALUE -->
<cfcase value="GTE 1"> // A TEST CASE --->
<cfset variables.cordial = "You failed to submit the following fields:" & "#variables.emptymsg#">
</cfcase>
<cfcase value="">
<cfset variables.cordial = "Thank you for providing your information">
</cfcase>
** i'm testing for the counter variable here. this sets the conditional output for the user, variables.cordial .
<font color="#000080">
<p>
<cfoutput>#variables.cordial#</cfoutput> // <!--- A PLACE TO TEST SOME OUTPUT --->
</p>
<div class="twocolform"> // <!--- THE FORM BEGINS --->
<cfform method="post" action="#getcurrenttemplatepath()#">
<ol class="orderleft"><cfoutput>
<li class="decimal">First Name:<br /><cfinput type="text" name="name_first" value="#variables.name_first#" /></li>
** and finally, showing you how i've done the FORM so that the fields are re-populated on the second time around (if other fields were empty)
so, is everything being done the HARD way, or what? i look forward to a reply, and hopefully someone might have a suggestion for improvement-- or even a link to a resource which might help me to get through this a little better?