creating specific sessions for specific users
<p>I am trying to create a sessions and entry to pages based on a person's "role" in the database. I thought I nailed the logic and I created the code. It worked. Problem is, it works for everyone. I wanted some help to point out why my code is logically incorrect when to me it's on point. Any help will be greatly appreciated. Here is my code. It seems to let in anyone who's role is not 'Admin' and I can pin point why:</p>

<pre><code>function auth($email, $pass){
        global $result;

        while ($row = mysql_fetch_array($result)) {
            if($email == $row["email"] &amp;&amp; $pass == $row["password"])
            {
                return true;
            }
        }
        return false;
    }

    function test($email, $pass){
        $test1 = auth($email, $pass); &lt;--above
        if ($test1) {
           get_role($email); &lt;-- below (This is the one where I'm puzzled)
        $_SESSION['email'] = true;
            header('location:menupage.php');
            exit;      
        }
        else{
            echo "Please enter correct username and password or &lt;a href='register.php'&gt;Register&lt;/a&gt;";}
    }

    function get_role($email){
    global $connection;
    $sql="SELECT * FROM exam WHERE email= '$email'";
    $result = mysql_query($sql, $connection);
    confirm_query($result);
    while ($row = mysql_fetch_array($result)) {
        if ($row["role"] == 'Admin'){
                $_SESSION['role'] = true;
            }
            else
            $_SESSION['role'] = false;
    }


    }
</code></pre>

<p>and this is the header for the administrative page that has the session</p>

<pre><code>&lt;?php
session_start();
if(!isset($_SESSION['role']))
{   $_SESSION['msg'] = 'you are not logggedd in';
    header('location: menupage.php');
    exit;
}
?&gt;
</code></pre>
