Code Comments
Programming Forum and web based access to our favorite programming groups.That makes sense now. I've re-written the form as one page with two forms,
as shown below, and it works like a champ. Thank you!
form.php -----
<?php
// Load the QuickForm code
require "HTML/QuickForm.php";
$form1 = new HTML_QuickForm("form1", null, null, null, null, true);
$form2 = new HTML_QuickForm("form2", null, null, null, null, true);
$form1->addElement("text","entered_text","Enter some text");
$form1->addRule("entered_text","You must enter text","required");
$form1->addElement("submit","submit","Submit");
$valid = $form1->validate();
If ($valid) {
$form2->addElement("static",null,"You Entered :". $_POST["entered_text"]);
$form2->addElement("submit",null,"Reset");
$valid = $form2->validate();
If ($valid) {
}
$form2->display();
} else {
$form1->display();
}
?>
On May 27, 2005, Justin Patrin wrote:
>
> On 5/27/05, Lionel Worman <lworman@wittenberg.edu> wrote:
> $_GET
> take
>
> 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.
>
> something
> should
> it
>
> 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
>
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.