Since the file is in your theme directory, WordPress may not want the user to “directly” access it. Why not create a Page in wordpress, assign a Template Name to your PHP page and then assign that to the new page created in wordpress. For example, you would have a new page called “Members Only” and its template is “php-page-located-in-theme”. Then, in the code, you don’t have to call the blog header, just simply wrap the entire page in your “Is user logged in” if else statement.
Example:
<?php
Template Name: php-page-located-in-theme
get_header();
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
/*PHP Generated Content Goes Here*/
} else {
echo 'You cannot access this page.';
}
get_sidebar();
get_footer();
?>