EDIT: is there a way to do this without reloading the page? I have a class that shows up when "Login" is pressed but it goes away quickly because the page is reloaded
I'm trying to test to see if a specific link text has been clicked because the same link can either have the texts "Login" or "Logout", but it's not registering that it's a valid link at all
index.php:
 <body>
        <nav>
            <ul>
                <li id="login">
                    <?php
                        if (isset($_SESSION['logged_user'])) 
                            echo "<a href='index.php?link=login'>Login";
                        else
                            echo "<a href='index.php?link=logout'>Logout";
                    ?>
                    </a>
                </li>
            </ul>
        </nav>
//LOGOUT
                if ($_GET['link']=='logout') {
                    unset($_SESSION["logged_user"] );
                    unset( $_SESSION );
                    $_SESSION = array();
                    session_destroy();
                }
error:
Undefined index: link
 
     
     
    