M213081
M213081

Reputation: 55

PHP user styling not in line with existing style

I am using a standard navbar-right for a navbar with bootstrap. Everything is fine until I use PHP for the username and it becomes out of line.

<ul class="nav navbar-nav navbar-right">
    <li><a href="#" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-user"></span><?php echo $_SESSION['username'];?></li>
    <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>      
</ul>

The above is my current code and the PHP ends up above the Sign Up text. Is it possible to fix this with CSS? The problem.

enter image description here

Upvotes: 1

Views: 23

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72299

I think it should be like below:-

<ul class="nav navbar-nav navbar-right">
    <?php if(!empty($_SESSION['username'])){?>
        <li><a href="#" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-user"></span><?php echo $_SESSION['username'];?></li>
    <?php }else{?>
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
    <?php}?>
</ul>

Note:- when session have username then why sign-up link there? Isn't it. If yes then my code will perfectly fine for you

Upvotes: 1

Related Questions