I am trying to conditionally create a fieldset in the top right of my website that will either prompt the user to login, or show their username and give them the option to logout.
I am using embedded php within my html document in order to achieve this. Unfortunately, both fieldsets are being displayed on my webpage. Can someone please explain to me what I am doing wrong? Thank you!
    <div id="loginForm">
            <?php 
            session_start();
            if(isset($_SESSION['username'])){ ?>
                <form action="endsession.php" method="post">
                <fieldset width="100">
                <legend>Welcome</legend>
                <h3></h3>
                <input type="submit" value="Logout"></input>
                </fieldset>
                </form>
            <?php } else{ ?>
                <form action="connection.php" method="post">
                    <fieldset width="100">
                    <legend>Login</legend>
                    <input type="hidden" name="submitted" id="submitted" value="1"/>
                    <label for="username">Username:</label>
                    <input id="username" name="username" type="text" ><br><br>
                    <label for="password">Password:</label> 
                    <input id="password" name="password" type="password"/><br><br>
                    <input type="submit" value="Sign in"></input>
                    </fieldset>
                    </form>
            <?php } ?>
        </div>
 
    