Q:

(PHP) Using two tables for a login query; other user not logging in?

We were instructed to use two tables for different type of user (Super admin and Admin) which made our codes more complex than it should be.
I have a login query where I validate if the user has been disabled by a superadmin account.
However, my codes only logs in Admin accounts, and every time I try to log in a super admin account, it only shows the last Else where it says I used an invalid password/user.
<?php
    include "config.php";
    if(isset($_POST['username']) && isset($_POST['password']))
    {
        $username = $_POST ['username'];
        $password = md5($_POST['password']);
        $stmt = $db -> prepare("SELECT * FROM users WHERE username=? AND password=?");
        $stmt -> bindParam(1, $username);
        $stmt -> bindParam(2, $password);
        $stmt ->execute();

        $stmt2 = $db -> prepare ("SELECT * FROM sa_users WHERE username=? AND password=?");
        $stmt2 -> bindParam(1, $username);
        $stmt2 -> bindParam(2, $password);
        $stmt2 ->execute();

        $row = $stmt->fetch();
        $row2 = $stmt2->fetch();

        $user = $row['username'];
        $pass = $row['password'];
        $id = $row['user_id'];
        $id2 = $row2['sa_id'];
        $type = $row['type'];
        $type2 = $row2['type'];
        $user_status = $row['user_status'];

        if ($user_status == 'Disable')
        {
?>

<div class="alert">
<span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
<strong>Error!</strong> Your account has been disabled!
</div>

<?php
        } else {

            if($username==$user && $pass==$password && $type2 == 'Super_Admin')
            {
                session_start();
                $_SESSION['username'] = $user;
                $_SESSION['password'] = $pass;
                $_SESSION['sa_id'] = $id2;
                $_SESSION['type'] = $type2;
?>

<script>window.location.href='index.php'</script>

<?php
            } else {
                if ($username==$user && $pass==$password && $type=='Admin')
                {

                    session_start();
                    $_SESSION['username'] = $user;
                    $_SESSION['password'] = $pass;
                    $_SESSION['user_id'] = $id;
                    $_SESSION['type'] = $type;

?>

<script>window.location.href='index.php'</script>

<?php
                } else {
                    if ($username!=$user && $pass!=$password)
                    {
?>
        <div class="alert">
        <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
        <strong>Error!</strong> Wrong Password/Username.
        </div>

<?php                
                    }
                }
            }
        }
    }
?>

A:

Your if statement only checks for the admin user and password.
   It misses this variable initializations:         
$user2 = $row2['username'];
$pass2 = $row2['password'];

When you check for Super Admin login credentials, you check using the username and password from Admin table and not from Super Admin table. 
Hence:
if($username==$user && $pass==$password

Rather Than:
if($username==$user2 && $pass2==$password

There are also lines using Admin Values when they should be from Super Admin's.
Here's the code below I updated. Not tested it yet tho. Hopefully it runs fine.
<?php
    include "config.php";

    if(isset($_POST['username']) && isset($_POST['password']))  {
                $username = $_POST ['username'];
                $password = md5($_POST['password']);
                $stmt = $db -> prepare("SELECT * FROM users WHERE username=? AND password=?");
                $stmt -> bindParam(1, $username);
                $stmt -> bindParam(2, $password);
                $stmt ->execute();

                $stmt2 = $db -> prepare ("SELECT * FROM sa_users WHERE username=? AND password=?");
                $stmt2 -> bindParam(1, $username);
                $stmt2 -> bindParam(2, $password);
                $stmt2 ->execute();

                $row = $stmt->fetch();
                $row2 = $stmt2->fetch();

                        $user = $row['username'];
                        $pass = $row['password'];
                        $user2 = $row2['username'];
                        $pass2 = $row2['password'];
                        $id = $row['user_id'];
                        $id2 = $row2['sa_id'];
                        $type = $row['type'];
                        $type2 = $row2['type'];
                        $user_status = $row['user_status'];

                    if ($user_status == 'Disable')
                    {
                    ?>

                    <div class="alert">
                    <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
                    <strong>Error!</strong> Your account has been disabled!
                    </div>

                    <?php

                    } else {

                    if($username==$user2 && $pass2==$password && $type2 == 'Super_Admin')
                    {
                    session_start();
                    $_SESSION['username'] = $user2;
                    $_SESSION['password'] = $pass2;
                    $_SESSION['sa_id'] = $id2;
                    $_SESSION['type'] = $type2;
                    ?>

                    <script>window.location.href='index.php'</script>

                    <?php
                    } else {

                    if ($username==$user && $pass==$password && $type=='Admin')

                    {

                    session_start();
                    $_SESSION['username'] = $user;
                    $_SESSION['password'] = $pass;
                    $_SESSION['user_id'] = $id;
                    $_SESSION['type'] = $type;

                    ?>

                    <script>window.location.href='index.php'</script>

                    <?php

                    } else {

                    if ($username!=$user && $pass!=$password)
                    {
                    ?>
                        <div class="alert">
                        <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
                        <strong>Error!</strong> Wrong Password/Username.
                        </div>

                    <?php                

                }
            }
        }
    }

    }
    ?>
        <!--end of php -->

