Re: using QuickForm with URL like ... www.site.com?act=this_page

From: Date: Tue, 25 Oct 2005 01:26:06 +0000
Subject: Re: using QuickForm with URL like ... www.site.com?act=this_page
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21624@lists.php.net to get a copy of this message
On 10/24/05, l Burnerheimerton <lburnerheimerton@yahoo.com> wrote: > I want to include my QuickForm snippets as "includes" > in a page controller model. Sample code below. > > A link might go to: > www.site.com/index.php?act=next_page > > When they click on that link, the form displays > properly. But when the user clicks to submit the > button, it takes the "act=next_page" out of the URL so > it destroys what I am trying to do with the page > controller. > > How can I get the form to process AND 1)redisplay with > errors if it does not pass validation; 2)go back to > index.php?act=next_page if it does pass validation? > > Thanks. > > > index.php: > ==================================== > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; > charset=iso-8859-1"> > </head> > <body> > <p>Welcome</p> > <p>Click <a href="index.php?act=next_page">here</a> > </p> > <?php > if (isset($_GET['act'])) { > switch ($_GET['act']) { > case "next_page": > require_once 'form.php'; > } > } > ?> > </body> > </html> > > > form.php: > ==================================== > <?php > require_once "HTML/QuickForm.php"; > $form = new HTML_QuickForm('newCAR', 'GET', > $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] > . '&',NULL,NULL,true); You're sending your form via GET and have GET params in your action. I'm not sure if web browsers know how to deal with this properly. I suggest not putting any query string in the action and instead making those variables hidden values in your form. > $form->addElement('header', 'MyHeader', 'Testing > QuickForm'); > $form->addElement('text', 'MyTextBox', 'What is your > name?'); > $form->addElement('reset', 'btnClear', 'Clear'); > $form->addElement('submit', 'btnSubmit', 'Submit'); > if ($form->validate()) { > $form->freeze(); > // I know I would add redirect command here is it > passes validation > } > $form->display(); > ?> > -- Justin Patrin

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