Hi,
I am new to phplib oohform and template. I am having problem with this page because there is no <form action....></form> generated afterward. I just wondering do I need to put <form....</form> inside the template as well.
I have specified the form method and form name but it just doesn't appeared in the page source.
$form = "ContactForm";
$method = "POST";
$f->get_start($jvsname,$method,$action, $target, $form);
The documentation of phplib is provided little example on OOH form How should I put those submit button, cancel button
<?
require_once("./config/config.php");
$perm->check("user");
$tpl = new Template;
$tpl->set_file("contact_form", "contact_form.html");
$tpl->set_block("contact_form", "contact_form_block", "tpl_contact_form");
$tpl->set_var(array("pagetitle" => "Contact",
"title" => "<b>Contact</b>"));
$contactid = CCGetParam("contactid");
if ($contactid <> "")
{
$sql = new DB_eontap;
$sql->query("SELECT * from contact where contactid = $contactid");
$numrows = $sql->num_rows($sql);
while ($sql->next_record())
{
$name = $sql->f("name");
$company = $sql->f("company");
$jobtitle = $sql->f("jobtitle");
$ic = $sql->f("ic");
$workphone = $sql->f("workphone");
$workext = $sql->f("workext");
$mobilephone = $sql->f("mobilephone");
$faxnumber = $sql->f("faxnumber");
$pagernumber = $sql->f("pagernumber");
$emailaddress= $sql->f("emailaddress");
}
}
$f = new form;
$f->add_element(array("type"=>'text',
"name"=>'name',
"size"=>'60',
"valid_regex"=>'[a-z]*$',
"valid_e"=>'Letters only',
"icase"=>1,
"value"=>$name));
$f->add_element(array("type"=>'text',
"name"=>'company',
"size"=>'40',
"value"=>$company));
$f->add_element(array("type"=>'text',
"name"=>'jobtitle',
"size"=>'40',
"value"=>$jobtitle));
$f->add_element(array("type"=>'text',
"name"=>'ic',
"size"=>'15',
"value"=>$ic));
$f->add_element(array("type"=>'text',
"name"=>'workphone',
"size"=>'15',
"value"=>$workphone));
$f->add_element(array("type"=>'text',
"name"=>'workext',
"size"=>'5',
"value"=>$workext));
$f->add_element(array("type"=>'text',
"name"=>'mobilephone',
"size"=>'15',
"value"=>$mobilephone));
$f->add_element(array("type"=>'text',
"name"=>'faxnumber',
"size"=>'15',
"value"=>$faxnumber));
$f->add_element(array("type"=>'text',
"name"=>'pagernumber',
"size"=>'15',
"value"=>$pagernumber));
$f->add_element(array("type"=>'text',
"name"=>'emailaddress',
"size"=>'50',
"value"=>$emailaddress));
if ($submitname) // Is there data to process?
if ($err = $f->validate()) { // Is the data valid?
echo $err; // No; Display error
$f->load_defaults(); // Load form with submitted data
}
else {
/ Process data / // Data ok; Do something with it
}
$form = "ContactForm";
$method = "POST";
$f->get_start($jvsname,$method,$action, $target, $form); // Start displaying form
$tpl->set_var(array("name" => $f->get_element('name'),
"company" => $f->get_element('company'),
"jobtitle" => $f->get_element('jobtitle'),
"ic" => $f->get_element('ic'),
"workphone" => $f->get_element('workphone'),
"workext" => $f->get_element('workext'),
"mobilephone" => $f->get_element('mobilephone'),
"faxnumber" => $f->get_element('faxnumber'),
"pagernumber" => $f->get_element('pagernumber'),
"emailaddress" => $f->get_element('emailaddress')));
$f->get_finish();
$tpl->parse("tpl_contact_form", "contact_form_block", true);
$tpl->pparse("OUTPUT", "contact_form");
page_close();
?>