Contact form in 2 minutes

You just want a fully working contact form, have no more time to spend

That's the right place. Let's start.

  1. You need a php server with php 5.3 or newer running.

    For help, go to Install and run a local PHP server

  2. Add phpformbuilder folder at the root of your project.

    For help, go to Include required files on your page to build form

  3. Copy / paste the following php blocks into your page at the indicated locations :

    <!-- customize (according to the comments) then paste following code at the very beginning of your file  -->
    use phpformbuilder\FormExtended;
    include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/phpformbuilder/Form.php';
    include_once rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/phpformbuilder/FormExtended.php';
    // you can change the form name if you want
    $form_name = 'extended-contact-form';
    // choose your framework below
    // can be 'bs3', 'bs4', 'material' or 'foundation'
    $framework = 'bs4';
    // choose the options for email sending
    $email_config = array(
        'sender_email'     =>  '',
        'recipient_email'  =>  '',
        'subject'          =>  'contact from PHP Form Builder'
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (FormExtended::validateContactForm($form_name) === true) {
            $sent_message = FormExtended::sendContactEmail($email_config, $form_name);
    $form = new FormExtended($form_name, 'horizontal', 'novalidate', $framework);
    // this line does the magic form
    <!-- paste following code just before </head> -->
    <?php $form->printIncludes('css'); ?>
    <!-- paste following code between <body></body> where your form will be displayed -->
    if (isset($sent_message)) {
        echo $sent_message;
    <!-- paste following code just before </body> -->

Your form is ready, email will be sent when form is posted and validated.

If your browser throws an error 500, click button below to solve this.

Your browser has thrown this error because php can't find Form.php.

rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) should lead to the root of your project.
If works fine if your server is well configured, but it seems that's not the case.

To solve this, open ../phpformbuilder/server.php on your browser and follow the instructions.

More explainations about error 500 are available at