i just started to read about object-oriented programming using php. i took a code that will print some message but when i tried to open it, it doesn't show anything.. is there something wrong with my code or i just forget something? here's the code from a book.. please help. thanks in advance!
<?php
/*
* Class name: Form
* Description : A class that creates a simple HTML form
* containing only text input fields. The class has 3 methods.
*/
class Form
{
var $fields=array(); # contains field names and labels
var $processor; #name of program to process form
var $submit = "Submit Form"; # value for the submit button
var $Nfields = 0; # number of fields added to the form
/* Constructor: User passes in the name of the name of the script where
*form data is to be sent ($processor) and the value to show on the submit button.
*/
function __construct($processor, $submit)
{
$this->processor = $processor;
$this->submit = $submit;
}
/* Display form function. Displays the form.
*/
function displayForm()
{
echo "<form action='$this->processor)' method='post'>";
echo "<table width='100%'>";
for($j=1;$j<=sizeof($his->fields);$j++)
{
echo "<tr><td align=\"right\">
{$this->fields[$j-1]['label']}: </td>\n";
echo "<td>
<input type='text'
name='{$this->fields[$j-1]['name']}'>
</td></tr>\n";
echo "<tr><td colspan=2 align='center'>
<input type='submit'
value='{$this->submit}'></td></tr>\n";
echo "</table>";
}
/* Function that adds a field to the form. The user needs to
* send the name of the field and a label to be displayed.
*/
function addField($name,$label)
{
$this->fields[$this->Nfields]['name'] = $name;
$this->fields[$this->Nfields]['label'] = $label;
$this->Nfields = $this->Nfields + 1;
}
}
}
?>