Skip to main content
Participant
September 2, 2008
Question

Passing form variables to a template page.

  • September 2, 2008
  • 1 reply
  • 371 views
I created a form page which passes a form variable name 'orderNo'. When it hits the action page a <cfif>
statement deduces whether it has been used and exists in a database record. The <cferror> than
send the user to the (cferror assigned template page). I would like the user to see the form.orderNo variable they entered on the template page.

Code inside action page which test the form variable against records
<!--- query the database to find a match for the form variable 'orderNo'--->

<cfquery name="GetMatch" datasource="dbMHAM">
SELECT OrderNo
FROM tblMham
WHERE OrderNo = <cfqueryparam value="#form.orderNo#" cfsqltype="CF_SQL_LONGVARCHAR">
</cfquery>


<!--- if the record count for the order number is '0' then request the template
page to provide information to the user about the number already existing
in a record of the database--->

<cfif GetMatch.recordCount GT 0>
<cferror type = "request" template= OrderNo_ValidationPage.cfm>
<cfabort showerror="order number already used">

Template page output

<cfoutput>#orderNo#</cfoutput> you entered is found in a posted record.<br>
Hit the<strong> Internet explorer back button</strong> review the survey and enter a new number<br>
or edit the with the same order number you tried to use

Text
This topic has been closed for replies.

1 reply

Inspiring
September 2, 2008
For your specific problem, set the form variable to a session variable and use cflocation to go to the new page instead of cferror.

On a more general note, what kind of application do you have where the users have to come up with their own unique order numbers?
Sandy_SAuthor
Participant
September 2, 2008
Hi Dan,
thanks for getting back to me. The application uses the orderNo as a unique/primary key number. It is a factory order number used for product we create. We are tracking the makeup of the equipment for the machine history.