PHP code example of romash1408 / formchecker

1. Go to this page and download the library: Download romash1408/formchecker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

romash1408 / formchecker example snippets


try
{
    $checker->work($_POST["formname"]);
}
catch (FormException $e)
{
    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';
}
 php
$_POST = [
    "formname" => "mainform",
];
 php
$_POST = [
    "formname" => "mainform",
    "phone" => "+7 (999) 999-99-9",
    "email" => "test",
];

try {

    $checker->work($_POST["formname"]);

} catch (FormException $e) {

    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';

}
 php
$_POST = [
    "formname" => "mainform",
    "phone" => "+7 (999) 999-99-99",
    "email" => "[email protected]",
];

try {

    $checker->work($_POST["formname"]);

} catch (FormException $e) {

    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';

}
 php
$_POST = [
    "formname" => "mainform",
    "name" => "Tester",
    "phone" => "+7 (999) 999-99-99",
    "email" => "[email protected]",
];

try {

    $checker->work($_POST["formname"]);

} catch (FormException $e) {

    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';

}
 php
$_POST = [
    "formname" => "mainform",
    "name" => "Tester",
    "phone" => "+7 (999) 999-99-99",
    "email" => "[email protected]",
    "list" => [
        "One", "Four",
    ],
];

try {

    $checker->work($_POST["formname"]);

} catch (FormException $e) {

    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';

}
 php
$_POST = [
    "formname" => "mainform",
    "name" => "Tester",
    "phone" => "+7 (999) 999-99-99",
    "email" => "[email protected]",
    "list" => [
        "One", "Three",
    ],
];

try {

    $checker->work($_POST["formname"]);

} catch (FormException $e) {

    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';

}
 php
$_POST = [
    "formname" => "contactform",
    "author" => "[email protected]",
    "message" => <<<TEXT
Helo, this is a test of FormChecker.
It is using <a href='http://php.net/manual/ru/function.htmlspecialchars.php'>htmlspecialchars</a>,
Su users can not <script>hack(you);</script>
TEXT
];

try {

    $checker->work($_POST["formname"]);

} catch (FormException $e) {

    echo '<h2 style="color: red">' . $e->getMessage() . '</h2>';

}