Need help with Formr?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

218 Stars 50 Forks GNU General Public License v2.0 85 Commits 2 Opened issues


Create and Validate PHP Forms in Seconds.

Services available


Need anything else?

Contributors list

No Data


Formr is a PHP micro-framework which installs easily and helps you build, layout and validate forms quickly, painlessly, and without all the complicated, messy overhead.

Find docs here:

If you find Formr useful, please consider starring the project and/or making a donation. Thank you!


  • Create complex forms with server-side processing and validation in seconds
  • Built-in support for Bootstrap and Bulma
  • Built-in support for reCAPTCHA v3
  • Built-in
    validation rules, including validating email, regex, comparisons, slugging, and hashing
  • Instantly make one field required, all fields required, or all but one field required
  • Create and validate radio groups and checkbox arrays in seconds
  • Upload images: resize, rename, and create thumbnails
  • Extensible: easily create and save your own field element wrappers
  • Extensible: easily create and save your own dropdown menus
  • Extensible: easily create and save your own form & validation sets
  • Send plain text and HTML emails
  • Generate CSRF tokens and honeypots
  • Object-oriented; supports multiple forms per page
  • Little helpers to assist in building, layout, testing and debugging
  • And a ton of other cool stuff!



Run the following command to install Formr with Composer

composer require formr/formr

Then include the

file and create a new form object.
require_once 'vendor/autoload.php';
$form = new Formr\Formr();


Download the .zip file and place the Formr folder in your project, then include the Formr class and create a new form object.

require_once 'Formr/class.formr.php';
$form = new Formr\Formr();

Bootstrap & Bulma Ready

Bootstrap and Bulma form classes are ready to go! Just tell Formr you want to use Bootstrap or Bulma when creating a new form and Formr will take care of the rest.

$form = new Formr\Formr('bootstrap');
$form = new Formr\Formr('bulma');

Basic Example

Simply enter your form labels as a comma delimited string and Formr will build the form, complete with opening and closing tags, a submit button, and email validation - plus all values retained upon

. Easy!
$form = new Formr\Formr('bootstrap');
$form->create_form('Name, Email, Comments|textarea');

Produces the following HTML

<div id="_name" class="form-group">
    <label class="control-label" for="name">
    <input type="text" name="name" id="name" class="form-control">

<div id="_email" class="form-group">
    <label class="control-label" for="email">
    <input type="email" name="email" id="email" class="form-control">

<div id="_comments" class="form-group">
    <label class="control-label" for="comments">
    <textarea name="comments" id="comments" class="form-control"></textarea>

<div id="_button" class="form-group">
    <label class="sr-only" for="button"></label>
    <button type="submit" name="button" id="button" class="btn btn-primary">Submit</button>

Basic Example with More Control

Using the

method tells Formr you want control over adding the form tags and submit button yourself. Otherwise it's the same as the Basic Example above.
$form = new Formr\Formr('bootstrap');
$form->create('First name, Last name, Email address, Age|number, Comments|textarea');

Produces the following HTML


Pre-Built Forms

Formr has several common forms already baked in, and it's really easy to create and save your own.

$form = new Formr\Formr();

Produces the following HTML


    <label for="lname">
        Last name:
    <input type="text" name="lname" id="lname" class="input">

    <label for="email">
    <input type="email" name="email" id="email" class="input">

    <label for="comments">
    <textarea name="comments" id="comments" class="input"></textarea>

    <input type="submit" name="submit" value="Submit" id="submit">

Build Forms With Arrays

$data = [
    'text' => 'name, Name:',
    'email' => 'email, Email:',
    'checkbox' => 'agree, I Agree',

$form = new Formr\Formr('bootstrap'); $form->fastform($data);

Produces the following HTML

    <div id="_email" class="form-group">
        <label class="control-label" for="email">
        <input type="email" name="email" class="form-control" id="email">

    <div id="_agree" class="checkbox">
        <label for="agree">
            <input type="checkbox" name="agree" value="agree" id="agree"> I Agree

    <div id="_submit" class="form-group">
        <label class="sr-only" for="submit"></label>
        <input type="submit" name="submit" value="Submit" id="submit" class="btn">

Build Forms in HTML

You have full control over how you build your forms...

text('name', 'Name'); ?>
email('email', 'Email address', '[email protected]', 'emailID', 'placeholder="[email protected]"'); ?>

Produces the following HTML

Retrieving POST Values

It's super easy to retrieve your

values and assign them to variables!
$name = $form->post('name');
$email = $form->post('email');


Formr can easly process and validate your forms

Like the

method, we can pass a list of our form labels to the
method, which will get the
values of our form fields and put them into an array. If your field name is
, a
validation rule will be applied automatically!

Basic usage

$form->validate('Name, Email, Comments');

Let's make sure the form was submitted, then we'll validate and get the value of our email field from the array.

if($form->submitted()) {
    $data = $form->validate('Name, Email, Comments');
    $email = $data['email'];

Adding Rules

Let's make sure

is a minimum of 2 characters and a maximum of 30 by adding our validation rules wrapped in parentheses.
$form->validate('Name(min[2]|max[30]), Email, Comments');

Fine-Tune Your Validation

Of course you can get more in-depth with your validation, and even add custom error messaging! The following is a basic example, however Formr's validation methods are quite powerful and include, among other things, comparing values between fields and hashing using


Let's get the value of our

field using the
$email = $form->post('email');

Now let's make sure it's a valid email address by entering the

validation rule in the third parameter. If there's an error, the text entered into the second parameter will notify the user to correct the
$email = $form->post('email','Email','valid_email');

We can take that a step further and enter a full custom error message in the second parameter to make our forms even more user-friendly.

$email = $form->post('email','Email|Please enter a valid email address','valid_email');

Full Example

// create our form object and use Bootstrap 4 as our form wrapper
$form = new Formr\Formr('bootstrap');

// make all fields required $form->required = '*';

// check if the form has been submitted if($form->submitted()) { // make sure our Message field has at least 10 characters $form->validate('Message(min[10])');

// let's email the form
$to = '[email protected]';
$from = '[email protected]';
$subject = 'Contact Form Submission';

// this processes our form, cleans the input, and sends it as an HTML email
if($form-&gt;send_email($to, $subject, 'POST', $from, 'HTML'))
    // email sent; print a thank you message
    $form-&gt;success_message('Thank you for filling out our form!');

} ?>

<meta charset="UTF-8">
<link rel="stylesheet" href="" crossorigin="anonymous">

<div class="container">
    <?php // print messages, formatted using Bootstrap alerts

        // create the form
        $form-&gt;create_form('First name, Last name, Email address, Message|textarea');

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.