rendered paste body<?php
/**
* @author Ionut Cosmin Gherghe
* @mail cosminlinux@gmail.com
* @copyright 2007
*/
class Form {
var $fields = array();
var $procesor;
var $submit = "Submit Form";
function __construct($procesor,$submit) {
$this->procesor = $procesor;
$this->submit = $submit;
}
function displayForm() {
echo "<form action = '{$this->procesor}' method = 'post'";
echo "<table>";
for each($this->fields as $field) {
echo "<tr><td>{$field['label'] }:</td>";
echo "<td><input type = 'text' name = '{$field['name']}'</td></tr>";
}
echo "<tr><td><input type ='submit' value = '{$this->submit}'></td></tr>";
echo "</form></table>";
}
function addField($name,$label){
$field = array('name' => $name, 'label' => $label);
$this->fields[] = $field;
}
}
echo "<html><head><title>Phone form</title></head><body>";
$phone_form = new Form("process.php","Submit Phone");
$phone_form->addField("first_name","First Name");
$phone_form->addField("last_name","Last Name");
$phone_form->addField("phone","Phone");
echo "<h3>Please fill out the following form:</h3>";
$phone_form->displayForm();
echo "</body></html>";
?>