<?php
    use App\MyUser;

    
    if (!isset($_POST['login'], $_POST['passwd'], $_POST['passwdconf'])) {
        header('Location: signup');
        exit();
    }
    if (empty($_POST['login']) || empty($_POST['passwd']) || empty($_POST['passwdconf'])) {
        header('Location: signup');
        exit();
    }
    
    $login = htmlspecialchars($_POST['login']);
    $passwd = htmlspecialchars($_POST['passwd']);
    $passwdconf = htmlspecialchars($_POST['passwdconf']);
    
    if ($passwd != $passwdconf) {
        header('Location: signup');
        exit();
    }

    try {
        $user = new MyUser($login, $passwd);
        $user->create();
        header('Location: signin');
        exit();
    }
    catch(Exception $e) {
        exit();
    }
    
    
    
        
