Newbee PHP HTML_QuickForm Best Way to process From Data
| From: | Sanjay | Date: | Wed, 07 Jan 2004 04:22:58 +0000 |
| Subject: | Newbee PHP HTML_QuickForm Best Way to process From Data | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10015@lists.php.net to get a copy of this message | ||
Hi,
What is best way from coding standards point of view to include Form
processing logic using HTML_QuickForm?
The current example includes function Process_Form. This method puts display
logic as well as procesisng logic into one .php file. Is this correct way or
do we put function in some different file and then include it here in this
code or use redirect method or there is any other good way.
Thanks
Sanjay
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testing PEAR HTML_QuickForm</title>
</head>
<body>
<?php
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('frmTest', 'post');
$form->addElement('header', 'MyHeader', 'Employee');
$form->addElement('text', 'Empno', 'Emp Id:');
$form->addElement('text', 'Ename', 'Name:');
$form->addElement('reset', 'btnClear', 'Clear');
$form->addElement('submit', 'btnSubmit', 'Submit');
if ($form->validate()) {
# If the form validates then freeze the data
$form->freeze();
$form->process('Process_Form',false);
}
else {
$form->display();
}
function Process_Form($value)
{
include('adodb/adodb.inc.php');
include('adodb/tohtml.inc.php');
$db = ADONewConnection('oci8');
$db->Connect(false, 'myuser', 'password', 'mydb');
$rs = $db->Execute('select * from emp');
print "<pre>";
rs2html($rs);
print "</pre>";
//print_r($value);
$db->Close();
}
?>
</body>
</html>