Stephanie, first you need a list of error checks to make against the form submission and the message to return to the user. Like, 'all fields required', 'email is not valid', 'password must be 5 characters long', etc.
You perform all the error check, insert into/update the dB on an action page, not the same page as the form. The reason is if the user keeps hitting the refresh button on the browser over and over, any code on that page will keep re-running, including insert into/update SQL code. Having an action page is much cleaner and easier to debug.
You wrap all error checking in a <cfif>/</cfif> statement, like:
Code:
<cfif FORM.Name NEQ "" and FORM.Email NEQ "">
<!--- if all is good, perform any task you want --->
<cfelse>
<!-- status 1: required fields missing
<cflocation url="formPage.cfm?status=1 addtoken="no">
</cfif>
Then back on the form page, you have a table cell that would display the error message template page, like:
Code:
<cfif isdefined("URL.status")>
<cfinclude template="statusMessages.cfm">
</cfif>
And, finally, create a statusMessage.cfm template that will have all your error message code that will load appropriately on any page that calls this template. This way you can use the same template site wide, and any change will be made on one page template page and not on all individual pages.
The statusMessages.cfm can look like:
Code:
<cfif isdefined("URL.Status")>
<cfif status EQ 1>Required fields missing.</cfif>
<cfif status EQ 2>Not a valid email.</cfif>
<cfif status EQ 3>Thank you for registering.</cfif>
</cfif>
There are many ways to do this, and i'm sure someone else will reply with another method. In the end you stick with a method that fits your needs.
Does this help?
____________________________________
Just Imagine.