<?php
    use App\MyUser;

        $login = htmlspecialchars($_POST['login']);
        $passwd = htmlspecialchars($_POST['passwd']);
        try {
            $user = new MyUser($login, $passwd);
            if (!$user->exists()) {
                header('Location: signin');
                $_SESSION['message'] = 'Bad password';
                exit();
            }
            $_SESSION['login'] = $login;
            header('Location: admin/welcome');
            exit();
        }
        catch(Exception $e) {
            $_SESSION['message'] = $e->getMessage();
            header('Location: signin');
            exit();
        }
