<?php

    
require_once 'HTML/QuickForm.php';
  
    class 
formHello extends HTML_QuickForm
    
{
        function 
formHello()
        {
            
// call the parent contructor specifying the name of the form
            // I'm setting 'post' here as the action type, but post 
            // is the default anyway
            
parent::HTML_QuickForm('formHello''post');
            
            
// add's a heading to the form
            // no field name is needed for this header
            // params: element type, fieldname, label
            
$this->addElement('header'null'Please enter your name');
            
            
// an input type="text" box 
            
$this->addElement('text''username''Your Name');
            
            
// a submit button
            
$this->addElement('submit''submit''Say Hello');
            
            
// adding a rule to make sure the user provides a username
            // params: fieldname, error message, rule type
            
$this->addRule('username''A username is required''required');
        }
        
        
// this function is called if the form is submitted and is valid
        
function process()
        {
            
// lock the form so it can't be editted
            
$this->freeze();
            
            
// say hello to the user!
            
echo "Hello " $this->exportValue('username') . "<hr />";
        }
    }    


    
$form = new formHello();
    if (
$form->validate())
    {
        
$form->process();
    }
    
$form->display();
?>