}
    if (empty($appointment)) {
        $appointmentErr = "Appointment is Required !";
    }
    if (empty($email)) {
        $emailErr = "Email is Required !";
    }
    if (empty($username)) {
        $usernameErr = "User Name is Required !";
    }
    if (empty($role)) {
        $roleErr = "Role is Required !";
    }
    if (!empty($first_name) && !empty($middle_name) && !empty($appointment) && !empty($email) && !empty($username) && !empty($role)) {
        $model = new SystemUsersModel();
        if ($model->fetch($username, $email) == 0) {
            if ($model->addUser($first_name, $middle_name, $last_name, $appointment, $email, $username, $password, $role) > 0) {
                header("location : users.php");
            } else {
                $error = "Addition of new User Failed !";
            }
        } else {
            $error = "Username or email already exists";
        }
    }
}
?>
<html>
    <head>
        <link href="../css/style.css" rel="stylesheet" type="text/css"/>
        <style type="text/css">