Skip to main content
Known Participant
December 4, 2008
Question

procssing forms with Application.cfc

  • December 4, 2008
  • 2 replies
  • 412 views
I have two forms in my site both with an input field Username. I want to process these with Application.cfc. one is on a contact page, one is on a signup for info page. How do differentiate between the two forms?

<cfif isDefined("form.username")>
//do some contact stuff
</cfif>

<cfif isDefined("form.username")>
//do some signup stuff
</cfif>

Thanks,


H.

This topic has been closed for replies.

2 replies

Inspiring
December 4, 2008
Use another field to identify the form being submitted.

By the way, using application.cfc to process forms is unorthodox to say the least. You are attemping to use it for something it wasn't designed for.
Inspiring
December 4, 2008
i assume you have that code in onRequestStart method?
you can then try this:

<cffunction name="onRequestStart" access="public" returntype="boolean"
output="true">
<cfargument name="TargetPage" type="string" required="yes" />
...
<cfif isDefined("form.username")>
<cfif getfilefrompath(arguments.targetpage) is "contact.cfm">
do the contact stuff
<cfelseif getfilefrompath(arguments.targetpage) is "signup.cfm">
do signup stuff
</cfif>
</cfif>
...
</cffunction>

i am not 100% sure this will work at all, as i am not sure if
onRequestStart method actually gets the posted form vars or not without
explicitly posting them to that method... i think it should, but i am
not sure...

then again, this kind of not the best cfc practice, accessing external
scopes/variables without explicitly passing them to the cfc...

i usually use a designated action page for each form, or have the form
submit ot itself and the processing code in the same page...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/