Use the InsertEvent() function to create the appointment. Remove ['authGroup'] variable and getUserData() function.
Remove $_SESSION['authGroup'] variable.
Remove $_SESSION['authGroup'] variable and duplicate getUsername() function.
Remove $_SESSION['authGroup'] variable.