| 
<?php
require_once('SimpleForm.php');
 
 /**
 * Initialize SimpleForm with parameters
 * Syntax: SimpleForm($formName, $method)
 * $formName - You only have to fill this in if you have more than 1 form on the page
 * $method - Form's method: default is 'post', you can also use 'get', but it's not recommended
 */
 $form = new SimpleForm('mihai', 'post');
 
 /**
 * Adds an element to the form
 * Syntax: addElement($label, $type, $required, $errorMessage)
 * $label - Label that represents the element
 * $type - Type of element; right now only input-text, input-password, textarea and input-submit
 *            are implemented
 * $required - Determines if field completion is required; if true you will have to set $errorMessage
 * $errorMessage - Error message to show in case field is not filled in
 */
 $form->addElement('Name', 'input-text', true, 'Please complete the name field!');
 $form->addElement('Email', 'input-text', true, 'Please complete the email field!');
 $form->addElement('Subject', 'textarea');
 $form->addElement('Send', 'input-submit');
 
 /**
 * If you want to show a success message after the form is shown, set it through this method
 * Syntax: addSuccessMessage($message)
 * $message - Message that you want shown after the form is completed
 */
 $form->addSuccessMessage('Congratulations! You will be contacted as soon as possible!');
 
 /**
 * Runs the form generator
 * At first it will just show the form
 * If the users submits the form with the required fields uncompleted, it will reshow the form plus the error message(s)
 * If everything is okay, it will just show the success message (if filled in) or nothing
 * Syntax: runForm($returnValues)
 * $returnValues - default is false; if set to true you'll have to capture the output from the return value
 *                    like $output = $form->runForm(true); and echo it yourself
 */
 $form->runForm(false);
 
 /**
 * If you need to send an email (or emails) with the form's content, do it with this method
 * Syntax: mailTo($to, $from, $subject)
 * $to - can be a form element(for example 'Email') in which case it will use the value entered by the user
 *          or a plain email address
 * $from - can be a form element(for example 'Email') in which case it will use the value entered by the user
 *            or a plain email address
 * $subject - Email's subject message
 */
 $form->mailTo('[email protected]', 'Email', 'Contact form email' );
 
 |