Processing 2 quickforms in a single php file
| From: | Zain Zafar | Date: | Wed, 11 May 2005 21:28:52 +0000 |
| Subject: | Processing 2 quickforms in a single php file | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19169@lists.php.net to get a copy of this message | ||
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();
}
?>