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 : 2 of 5 (graded 4 times)
Viewed : 4933
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

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

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
Database and Recordset classes fo SyBASE Usage is obvious.
Categories : Sybase, Databases, PHP Classes, PHP
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
Gonx URLs - This class is meant to generate URLs for accessing application dynamically generated pages based on parameters passed in the URL.
Categories : PHP, PHP Classes, Navigation, URLs
SPL and ITERATOR : examples
Categories : PHP, Object Oriented, PHP Classes, Sessions
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item.
Categories : PHP Classes, PHP, Java Script, DHTML
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
XPertMailer - Sends TRUE Mails
Categories : PHP, Mail, SMTP, PHP Classes
PHP VXML Class : How to use PHP in VoiceXML applications
Categories : PHP, PHP Classes, VXML