Re: TrackSubmit question

From: Date: Fri, 27 May 2005 21:07:50 +0000
Subject: Re: TrackSubmit question
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19392@lists.php.net to get a copy of this message
On 5/27/05, Lionel Worman <lworman@wittenberg.edu> wrote: > I'm having some trouble working with the $trackSubmit option of > HTML_Quickform. The documentation mentions the following about it: > > "boolean $trackSubmit > > (optional) Whether to track if the form was submitted by adding a > special hidden field. If the name of such field is not present in the $_GET > or $_POST values, the form will be considered as not submitted. " > > 1st Question: is meant by adding a special hidden field, and how do I take > advantage of it? trackSubmit automatically puts a hidden value in the form and the form won't validate if that value isn't in the submitted values. You don't have to do anything special to use it. It's mostly there so that you can have 2 forms on one page so that QF can know which one was submitted. > > 2nd Question: I've set up the following page so that it requires something > be typed into the Text field entered_text. If the form is valid it should > post to the next page (form2.php). The problem is that as long as I have it > POST or GET to another page, it skips the validation. It skips the > validation no matter what I put in for tracksubmit. Well, this is because you're posting to form2.php, which doesn't check to see if form1.php is valid. PHP scripts are run completely, the output is sent to the browser, and the browser sends a response back. In this case, the browser is sending the response to form2.php, which isn't dealing with the submit of the first form. A better solution would be to leave the action alone and let the form submit to the page that created it (this is the "right" way to do it). Then the validation will work. If the form validates, process the data, then redirect to the second for with a header('Location: http://...'); -- Justin Patrin

« previous php.pear.general (#19392) next »