WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 5 times)
Viewed : 7367
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  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>



Forms protected from XSS attacks (FOPAXSS)
Categories : PHP, PHP Classes, Form Processing, Security
cPanel Email Accounts Creator
Categories : PHP, PHP Classes, Email, Form Processing, Web Services
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
FormChecker Package - validate any data via classes and patterns.
Categories : PHP, Form Processing, PHP Classes, Regexps
Form Elements Class
Categories : PHP, PHP Classes, Form Processing
How To Create a PDF Using PHP
Categories : PHP, PDF, PHP Classes, HTML and PHP
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email
Banknote Validation - A PHP class that provides several methods to quickly validate banknote serial numbers of the following currencies: AUD, CAD, CHF, CNY, EUR, GBP, JPY, USD.
Categories : PHP, PHP Classes, Data Validation, Regexps
Scramble Eggs - php class to scramble/encode
Categories : PHP, PHP Classes, Security, Encryption
Directory Listing To XML : Outputs XML File of a Given Directory Listing
Categories : PHP, PHP Classes, XML, Directories
Mssql database Manager
Categories : PHP, Databases, MS SQL Server, Classes and Objects, PHP Classes
A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
Automatic Browsers Detect
Categories : PHP, PHP Classes, Headers, Browsers
These PHP Classes Check if a host is alive using various methods.
Categories : PHP, PHP Classes, Sockets, CURL
A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security