using QuickForm with URL like ... www.site.com?act=this_page
| From: | l Burnerheimerton | Date: | Tue, 25 Oct 2005 00:33:02 +0000 |
| Subject: | using QuickForm with URL like ... www.site.com?act=this_page | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-21622@lists.php.net to get a copy of this message | ||
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);
$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();
?>
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com