require_once 'services.php';
include_once 'config.php';
// REGISTRAZIONE
if ($_SERVER["REQUEST_METHOD"] == 'POST') {
    if (isset($_POST["email"])) {
        if (isset($_POST["password"])) {
            if (isset($_POST["username"])) {
                $res;
                $email = htmlspecialchars($_POST['email']);
                $password = sha1(sha1(htmlspecialchars($_POST['password'])));
                $username = htmlspecialchars($_POST['username']);
                if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                    if (!empty($username)) {
                        $service = new Services();
                        $res = $service->saveUser($email, $username, $password);
                    } else {
                        $res = USERNAME_NULL;
                    }
                } else {
                    $res = INVALID_EMAIL;
                }
            } else {
                $res = USERNAME_NULL;
            }
        } else {
            $res = PASS_NULL;
        }
    } else {
        $res = EMAIL_REQUIRED;
    }