Re: Processing 2 quickforms in a single php file
| From: | Jens Kleikamp | Date: | Thu, 12 May 2005 12:41:16 +0000 |
| Subject: | Re: Processing 2 quickforms in a single php file | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19172@lists.php.net to get a copy of this message | ||
Zain Zafar wrote:
> Hello. Can I process 2 quickforms in a single php file ? One of them comes
> wit $action=form1 and the other $action=form2. I've written down the
> sample code here.. please correct me if i am wrong or even if its possible
> or not
>
> //CODE STARTS
> <?php
> //requiring all necessary files
>
> $action = (isset($_GET['action'])) ? $_GET['action'] : "null";
> $form = new Html_QuickForm('myform');
> if ($action == 1) {
> $form->addElement('text', 'name', 'Enter Name:');
> $form->addRule('name', 'Required Name', 'required');
> $form->addElement('password', 'pass1', 'Enter
> Password:');
> $form->addElement('password', 'pass2', 'Confirm
> Password:');
> $form->addRule(array('pass1', 'pass2'), 'Comparison
> Failed',
> 'compare'); $form->addElement('submit', 'btsubmit',
> 'Submit');
> if ($form->validate()) { $form->freeze(); }
> $form->display();
> }
>
> if ($action == 2) {
> $form->addElement('text', 'email', 'Email:');
> $form->addRule('email', 'Invalid Email', 'email', null,
> 'client');
> $form->addRule('email', 'Required', 'required', null,
> 'client');
> $form->addElement('text', 'Name', 'Name:');
> $form->addElement('submit', 'btsubmit', 'Submit');
> if ($form->validate()) { $form->freeze(); }
> $form->display();
> }
> ?>
Try to use two seperate quickform objetcs instead of using one object for
two forms.
$form1 = new HTML_QuickForm(....);
$form2 = new HTML_QuickForm(....);
Have also a look at the trackSubmit option, see the pear manual.
Best Regards,
Jens