StructAppend, form variables, and the GET method

I made a very silly mistake today. I was putting my url and form variables into the request scope through the application.cfm file

<cfset StructAppend(request, url, "no")>
<cfset StructAppend(request, form, "no")>

Next I had a form page, which was using the GET method to post the form (simplified below).

<form action="formAction.cfm" method="GET">
<input type="hidden" name="reportId" value="#url.reportId#">
<textarea cols="40" rows="3" name="reportComment"></textarea>
<input type="submit" value="Add Comment">

On the form action page, I was referencing form.reportId, and it was bombing since it did not exist. In fact, the form scope did not exist at all! The values existed in the request scope, so what happened? Did the StructAppend call removes the form scope after it appended it to the request scope? After about five minutes, I remembered that the GET method of posting a form passes all variables through the URL string rather than a form scope.

My mistake was easily fixed by changing the form method to POST, or by simply referencing the REQUEST scope, which I should have been doing in the first place!

Silly mistake. I'm glad nobody knows I did that.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.