仅当用户是管理员时才显示链接

I am very new to PHP and I am trying to make a registration form only for an admin(no need for other users). I want to show one of the menu nav ("Add photo") only to admins.

LOGIN.php:

<?php
    include_once 'header.php';

    $username = "Efren";
    $password = "111";

    if (($_POST['txt_uname_email'] == $username)&& ($_POST['txt_password'] == $password)) {
        session_start();
        $_SESSION['admin_is_logged'] = true;
        echo '<script type="text/javascript"> window.open("homepage.php","_self");</script>';            
    }

This is the part of the header that I am trying to show only to admins:

<?php 
    if (isset($_SESSION['admin_is_logged']) && $_SESSION['admin_is_logged'] == true){
        echo '<li><a href="/addnew.php">add photo</a></li>';
    }
?>
</ul>

Right now “add photo” is hidden both to admin and other visitors.

You need to start session on every page you want access to $_SESSION variable. I saw your session_start is inside if statement. Just set it on top of every file (where you need session) and it should work.

Put

session_start();

on file beginning just after <?php