I am using the following code to check the user permission (User Role).

This is to check whether the user is logged in or not

<?php
    session_start();
    if (!isset($_SESSION["username"])) {
        echo '<script>window.location.href = "userLogin/?notloggedin=true";</script>';
    }
?>

This is to check whether is an admin or not

    <?php
        session_start();
        if ($_SESSION["user_group"] == 'admin') {
            //Display the current page.
        }
        else
            {
                //display an full page error without showing any other content in the current page.
            }
    ?>

My question is, how can I display a full page error instead of page content?

    <?php
    session_start();
    if (!isset($_SESSION["username"])) {
            header("userLogin/?notloggedin=true"); //may need to use absolute or different relative address
            exit;
    }elseif($_SESSION["user_group"] !== 'admin') {
            header("whateverPage/?notadmin=true"); //may need to use absolute or different relative address
            exit;
    }
    //carry on with showing the page if logged in and admin
    ?>