I'd just like to offer one other alternative for posting a page to itself. Rather than looking to see if a hidden (or other expected) form field is "defined", you could also test for the cgi variable request_method having a value of "post". It will be "get" when the page is requested to "show" the form (typically) and then "post" when it's submitted. The code would be:
 
<cfif cgi.request_method is "post">
    process the form
<cfelse>
    show the form
</cfif>
 
Of course, you could reverse the order of testing. Just don't be tempted to test for 'is not "get"' as the first test above to do the form processing. It may seem logical, but the values are not binary. Besides "get" and"post", there's "head" and others. And some search engine tools do send requests with other methods. If you test for 'not "get"', it would cause execution of your form submission code that would fail because the expected form variables aren't there.
 
/charlie
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of nolan
Sent: Monday, April 08, 2002 4:09 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFTALKTor] Post to Self

 

Hi Mike,

 

You could do something like this:

 

 

<cfif isDefined(“FORM.Post”)>

 

something happens here…..<br>
            <cfoutput>#FORM.username#, #FORM.password#</cfoutput>

 

</cfif>

 

 

<form name=”PostForm” method=”post” action=”thispage.cfm”>

 

<input type=”text” name=”form1” value=”username”>

<input type=”text” name=”form2” value=”password”>
            <input type=”hidden” name=”Post” value=”Post”>

<input type=”submit” name=”submit” value=”Submit”>


</form>

 

 

The form page submits to itself and the code within the conditional statement will execute only if the value FORM.Post is passed.

 

 

Nolan

 

 

 

 

 

Nolan J. Dubeau
Senior Developer, (*Maracca)

Application Design & Technology

------------------------------------------------

p. 416.532.8852

e. [EMAIL PROTECTED]

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Mike
Sent: Monday, April 08, 2002 3:44 PM
To: [EMAIL PROTECTED]
Subject: [CFTALKTor] Post to Self

 

Hi All,

 

Please excuse the beginner question.  I am trying to make pages that post to themselves.  I there a way to set up a variable that that dynamically includes the template name so I don't have to keep changing the template name when I reuse a form.

 

Thanks

 

Mike

Reply via email to