WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Auto HTML Forms
Categories : PHP, PHP Classes, Form Processing
ROBERTO ALEMAN
Date : Dec 07th 2009
Grade : 3 of 5 (graded 2 times)
Viewed : 1688
File : No file for this code example.
Images : No Images for this code example.
Search : More code by ROBERTO ALEMAN
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

This class can be used to compose and output HTML forms.

It can generate HTML form different types of form inputs and other types of HTML elements given parameters that defines details of each type of element.

The generated HTML is returned as a string that can be assembled with other parts of the final HTML page.

autohtmlforms.php
<?php
class autohtmlforms{
     public function
TextFieldEng($id,$class,$textfieldname,$type,$value,$size,$maxlegth)
    {
           
$textfield_eng = "$textfieldname:<input name='$textfieldname' type='$type' id='$id'  class='$class' value='$value' size='$size' maxlength='$maxlegth' />";
            return
$textfield_eng;
    }
    public function
TextAreaEng($id,$class,$TextAreaName,$Columns,$Rows)
    {
           
$textarea_eng = "$TextAreaName:<text area name='$TextAreaName' id='$id'  class='$class' cols='$Columns' rows='$Rows'></text area>";
            return
$textarea_eng;
    }
        public function
ButtonEng($id,$class,$button_name,$button_type,$button_value)
    {
            if (
$button_type!="submit")
            {
           
$button_eng = "<input name='$button_name' type='$button_type' id='$id  class='$class' value='$button_value'>";
            return
$button_eng;
            }
            else
           
$button_eng = "<input name='$button_name' type='$button_type' id='$id  class='$class' value='$button_value'></form>";
            return
$button_eng;
    }
    public function
Checkbuttoneng($id,$class,$CheckButtonName,$TypeCheckButton,$ValueCheckButton,$InitValueCheckButton)
    {
            if(
$InitValueCheckButton!=""){
               
$Checkbutton_eng = "<input name='$CheckButtonName' type='$TypeCheckButton' id='$id'  class='$class' value='$ValueCheckButton' checked='checked'>";
                return
$Checkbutton_eng;
            }
            else
            {
           
$Checkbutton_eng = "<input name='$CheckButtonName' type='$TypeCheckButton' id='$id'  class='$class' value='$ValueCheckButton'>";
                return
$Checkbutton_eng;
            }
    }
    public function
Radiobuttoneng($id,$class,$RadioButtonName,$TypeRadioButton,$ValueRadioButton,$InitValueRadioButton)
    {
            if(
$InitValueRadioButton!=""){
               
$Radiobutton_eng = "<input name='$RadioButtonName' type='$TypeRadioButton' id='$id'  class='$class' value='$ValueRadioButton' checked>";
                return
$Radiobutton_eng;
            }
            else
            {
           
$Radiobutton_eng = "<input name='$RadioButtonName' type='$TypeRadioButton' id='$id  class='$class' value='$ValueRadioButton'>";
                return
$Radiobutton_eng;
            }
    }
    public function
FormEng($id,$class,$action,$method,$encoding,$FormName,$target)
    {
           
$Form_eng = "<form action='$action' method='$method' enctype='$encoding' id='$id'  class='$class' name='$FormName' target='$target'>";
            return
$Form_eng;
    }
public function
nlabeleng($id,$class,$msg)
    {
               
$nlabel_eng = "    <label id='$id'  class='$class'>$msg</label>";
                return
$nlabel_eng;
    }
public function
Hr($id,$class)
        {
           
$H_r = "<hr id='$id'  class='$class'\>";
            return
$H_r;
        }
public function
Br($id,$class)
        {
           
$B_r = "<br  id='$id'  class='$class'\>";
            return
$B_r;
        }
public function
endForm()
{
$enform = "</form>";
return
$enform;
}

}
?>




examples.php
<?php
require_once("autohtmlforms.php");
$newtextf = new autohtmlforms(); //create textfield objet
$newbutton = new autohtmlforms();//create button objet
$newtextA = new autohtmlforms();//create textarea objet
$newcheckB = new autohtmlforms();//create checkbox objet
$newradioB = new autohtmlforms();//create radio objet
$newform= new autohtmlforms();//create form objet
//engine messages
$new_label = new autohtmlforms();
//engine <br> html tag
$newbr = new autohtmlforms();
$jump = $newtextf->Br();
//engine <hr> html tag
$newhr = new autohtmlforms();
$hr = $newhr->Hr();
// end form tag
$endform = new autohtmlforms();
/* Explane use*/
echo $newform->FormEng("examples.php","post","","form1","_self");  //"action url","method: get or post","encoding","form name","target"
echo $hr.$new_label->nlabeleng("Example of Textfield").$jump.$jump;
echo
$newtextf->TextFieldEng("Nombre","text","","50","50");  //"name","type","value","size","maxlegth"
echo $newtextf->TextFieldEng("Apellido","text","","50","50");  //"name","type","value","size","maxlegth"
echo $hr.$new_label->nlabeleng("Example of Text Area").$jump.$jump;
echo
$newtextA->TextAreaEng("Comentario","50","10");  //,"TextAreaName","columns","rows"
echo $hr.$new_label->nlabeleng("Example of Button").$jump.$jump;
echo
$newbutton ->ButtonEng("submit","submit","Submit");  //,"ButtonName","Buttontype","buttonvalue"
echo $hr.$new_label->nlabeleng("Example of Check Button").$jump.$jump;
echo
$newcheckB ->Checkbuttoneng("CheckButtonName","checkbox","ValueCheckButton","checked");  //"CheckButtonName","checkbox","ValueCheckButton","checked"
echo $newcheckB ->Checkbuttoneng("CheckButtonName","checkbox","ValueCheckButton","");  //"CheckButtonName","checkbox","ValueCheckButton","" <--- unchecked
echo $hr.$new_label->nlabeleng("Example of Radio Button").$jump.$jump;
echo
$newradioB ->Radiobuttoneng("RadioButtonName","radio","ValueRadioButton","checked");  //"RadioButtonName","Radio","ValueRadioButton","checked"
echo $newradioB ->Radiobuttoneng("RadioButtonName","radio","ValueRadioButton","");  //"RadioButtonName","Radio","ValueRadioButton","" <--- unchecked
echo $endform->endForm(); //show </form> tag if you not closed the form with submit buttom
?>
<p>/* this example engine is*/</p>
<p><form action='examples.php' method='post' enctype='' name='form1' target='_self'><hr \>    <label>Example of Textfield</label><br \><br \>Nombre:<input name='Nombre' type='text' value='' size='50' maxlength='50' />Apellido:<input name='Apellido' type='text' value='' size='50' maxlength='50' /><hr \>    <label>Example of Text Area</label><br \><br \>Comentario:<textarea name='Comentario' cols='50' rows='10'></textarea><hr \>    <label>Example of Button</label><br \><br \><input name='submit' type='submit' value='Submit'></form><hr \>    <label>Example of Check Button</label><br \><br \><input name='CheckButtonName' type='checkbox' value='ValueCheckButton' checked='checked'><input name='CheckButtonName' type='checkbox' value='ValueCheckButton'><hr \>    <label>Example of Radio Button</label><br \><br \><input name='RadioButtonName' type='radio' value='ValueRadioButton' checked><input name='RadioButtonName' type='radio' value='ValueRadioButton'></form></p>



FormChecker Package - validate any data via classes and patterns.
Categories : PHP, Form Processing, PHP Classes, Regexps
cPanel Email Accounts Creator
Categories : PHP, PHP Classes, Email, Form Processing, Web Services
Form Elements Class
Categories : PHP, PHP Classes, Form Processing
Forms protected from XSS attacks (FOPAXSS)
Categories : PHP, PHP Classes, Form Processing, Security
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Mssql database Manager
Categories : PHP, Databases, MS SQL Server, Classes and Objects, PHP Classes
AutoRSS
Categories : PHP, Rich Site Summary (RSS), PHP Classes
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
Recordset Class for MSSQL database
Categories : PHP Classes, Databases, PHP, MS SQL Server
The GTV.class allows you to extract a value between any HTML tag or between any TEXT on a web page.
Categories : PHP, PHP Classes, Regexps
HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout.
Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs
a class for doing payments to a cybercash server
Categories : Ecommerce, Complete Programs, PHP Classes, PHP
Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects.
Categories : PHP, PHP Classes, XML, Web Services