PHP mcForms Class
mcForms designed for easily creating and controlling to recently used HTML form objects. In mcForms, there are two classes named mcForm and mcComboBox.
Features
- Add form objects with their captions
- Assign maximum lengths and initial values
- Add most used JavaScript validations to objects
- Create comboboxes and fill them database query results
- No HTML knowledge required, do it all in a single row PHP code
Example Usage
// Include mcForms classes to your code
include("mcforms.php");
// Create an instance of mcForm class
$myForm = new mcForm("myform","index.php");
// Add text field with no parameters
$myForm->labelInput("email","E-mail");
// Add text field with max 20 length with has no initial value
$myForm->labelInput("username","Username",null,20);
// Add password field with max 20 length with has no initial value
$myForm->labelInput("password","Password",null,20,true);
// Add hidden field and set initial value to $foobar variable
$myForm->input("ip",$foobar,null,false,true);
// Create an instance of mcComboBox class
$cbCountry = new mcComboBox("country","Country");
// Add single value with their caption
$cbCountry->add("Please select...","0");
// Fill combobox with your query
$cbCountry->fill("select * from countries","countryCode","countryName","90");
// Finally close your combobox object
$cbCountry->close();
// Assign a "not null" property to field which named email
$myForm->isFilled("email","E-mail");
// Add email validation to same field
$myForm->validEmail("email","E-mail");
// Assign a "not null" property to field which named username
$myForm->isFilled("username","User name");
// Assign a "not null" property to field which named password
$myForm->isFilled("password","Password");
// Accept only numeric characters in password field
$myForm->isNumeric("password","Password");
// Set minimum length to six
$myForm->minLen("6","password","Password");
// Add submit with caption
$myForm->button("submitform","Submit Form");
// Finally close your form object
$myForm->close();
