<?php

require_once('config.php');

require_once('config.php');
require_once('classes/user.php');
$user_class = new User();

$app_settings = $user_class->getAppSettings();

if(!isset($app_settings['allow_registered']) || $app_settings['allow_registered'] != 1){
    header('Location: '.baseUrl('login.php'));
    die();
}

$name   = '';
$email  = '';
$error  = '';

if(isset($_POST['submit']) && $_POST['submit'] == 'create_user')
{
    $name       = empty($_POST['name']) ? '' : $_POST['name'];
    $email      = empty($_POST['email']) ? '' : $_POST['email'];
    $password   = empty($_POST['password']) ? '' : $_POST['password'];
    $rpassword   = empty($_POST['repassword']) ? '' : $_POST['repassword'];

    $result = $user_class->create($name,$email,$password,$rpassword);
    if(isset($result['success']) && $result['success']){
        header('Location: '.baseUrl('login.php'));
        die();
    }else{
        $error = $result['error'];
    }
}

include('templates/create.php');