navigation bar misplaced or just wrong codes. i don’t now what to do anymore

the navigation bar and side bar is not supposed to be in the admin log in page.

the navigation bar and side bar should only pop ups after i logged in as admin.

this is the admin log in page with navigation bar that not supposed to be there.
///picture///

yet this is what happened after i logged in, the design are not existing.

///picture///

i don’t understand why its wrong.

this is the code for that navigation bar and nav side bar.

` <?php

 if(is_admin_login())
{

?>
 <body class="sb-nav-fixed">
    <nav class="sb-topnav navbar navbar-expand navbar-dark bg-dark">
        <!-- Navbar Brand-->
         <a class="navbar-brand ps-3" href="index.php">Library System</a>
        <!-- Sidebar Toggle-->
        <button class="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" id="sidebarToggle" href="#!"><i class="fas fa-bars"></i></button>
        <form class="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
        </form>
        <!-- Navbar-->
        <ul class="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="fas fa-user fa-fw"></i></a>
                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                   <li><a class="dropdown-item" href="logout.php">Logout</a></li>
                </ul>
            </li>
        </ul>
    </nav>

    <div id="layoutSidenav">
        <div id="layoutSidenav_nav">
            <nav class="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
                <div class="sb-sidenav-menu">
                    <div class="nav">

                    <a class="nav-link" href="logout.php">Logout</a>

                    </div>
                </div>
                <div class="sb-sidenav-footer">
                   
                </div>
            </nav>
        </div>
        <div id="layoutSidenav_content">
            <main>

<?php 
}`

and this is the code for the admin login page where that code from above should not be here in admin log in page.

`<?php

//admin_login.php

include ‘database_connection.php’;

include ‘function.php’;

$message = ”;

if(isset($_POST[“login_button”]))
{

$formdata = array();

if(empty($_POST["admin_email"]))
{
    $message .= '<li>Email Address is required</li>';
}
else
{
    if(!filter_var($_POST["admin_email"], FILTER_VALIDATE_EMAIL))
    {
        $message .= '<li>Invalid Email Address</li>';
    }
    else
    {
        $formdata['admin_email'] = $_POST['admin_email'];
    }
}

if(empty($_POST['admin_password']))
{
    $message .= '<li>Password is required</li>';
}
else
{
    $formdata['admin_password'] = $_POST['admin_password'];
}

if($message == '')
{
    $data = array(
        ':admin_email'      =>  $formdata['admin_email']
    );

    $query = "
    SELECT * FROM lms_admin 
    WHERE admin_email = :admin_email
    ";

    $statement = $connect->prepare($query);

    $statement->execute($data);

    if($statement->rowCount() > 0)
    {
        foreach($statement->fetchAll() as $row)
        {
            if($row['admin_password'] == $formdata['admin_password'])
            {
                $_SESSION['admin_id'] = $row['admin_id'];

                header('location:admin/index.php');
            }
            else
            {
                $message = '<li>Wrong Password</li>';
            }
        }
    }   
    else
    {
        $message = '<li>Wrong Email Address</li>';
    }
}

}

include ‘header.php’;

?>

<div class="col-md-6">

    <?php 
    if($message != '')
    {
        echo '<div class="alert alert-danger"><ul>'.$message.'</ul></div>';
    }
    ?>

    <div class="card">

        <div class="card-header">Admin Login</div>

        <div class="card-body">

            <form method="POST">

                <div class="mb-3">
                    <label class="form-label">Email address</label>

                    <input type="text" name="admin_email" id="admin_email" class="form-control" />

                </div>

                <div class="mb-3">
                    <label class="form-label">Password</label>

                    <input type="password" name="admin_password" id="admin_password" class="form-control" />

                </div>

                <div class="d-flex align-items-center justify-content-between mt-4 mb-0">

                    <input type="submit" name="login_button" class="btn btn-primary" value="Login" />

                </div>

            </form>

        </div>

    </div>

</div>

`

i’m watching this from the youtube and carefully write codes line per line and yet the output i get is not the same as i watch from the youtube. this is the video link:

since this is my first time doing php. i used to do java coding.