Authentication using $_SERVER['SCRIPT_NAME']
<p>The users when they sign up are given a default 'member_type' as "User". I'm trying to restrict access to certain pages from "Users" and unauthenticated visitors using $_SERVER['SCRIPT_NAME'] using a function stored in the header.php.</p>

<p>The concept is sound (I believe) but I really need some fresh eyes to help me solve the logic.</p>

<p>Here is the function in the header:</p>

<pre><code>$basicAuth = array("member.php", "order.php", "logout.php");
    $adminonly = array("admin.php", "v_feedback.php", "user.php", "v_content.php", "product.php");


    restrictAccess($basicAuth, $adminonly);
</code></pre>

<p>And here is the function in its entirety:</p>

<pre><code>function restrictAccess($basicAuth, $adminonly){
$error = "You do not have the authentication privileges to access this area, go &lt;a href=\"index.php\" alt=\"Home\"&gt;home&lt;/a&gt;.";

    if (isset($_SESSION['type'])){
        $auth = "Basic";

        if($_SESSION['type']=="Admin"){
            $auth = "Admin";
        }
    } else {
        $auth = "None";
    }

    //For testing purposes
    echo $auth;



if ($auth == "None"){
    if(($_SERVER['SCRIPT_NAME']==$basicAuth)||($_SERVER['SCRIPT_NAME']==$adminonly)){
        echo $error;
        exit();
    }
}elseif($auth =="Basic"){
    if(($_SERVER['SCRIPT_NAME'])==$adminonly){
        echo $error;
        exit();
    }
}
</code></pre>

<p>}</p>

<p>I have a feeling that it something to do with the logic behind the way I've structured it which is to fault. </p>

<p>Thank you. </p>
