/Library

Checking form always takes time. In every project it is. Simple user registration? And only need check form. The library will have a set of basic functions for working with form.

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Library

// FORM.PHP

input id="lastname" type="text" name="lastname"
input id="name" type="text" name="name"
input id="email" type="text" name="email"
input id="phone" type="tel" name="phone"

// INDEX.PHP

include_once "src/autoload.php";

$server_requerst = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null;

if ($server_requerst == 'POST') {

    $form = new Form($_POST);
    if ($form->is_valid()) {
        var_dump('Данные введены корректно!');
    }
    else {
        var_dump('Ошибка ввода данных');
    }

}
else {

    include_once "form/Form.php";
}