关于PHP网页用户登陆后显示注销.而登陆前则只显示注册登陆连接的有关问题
关于PHP网页用户登陆后显示注销.而登陆前则只显示注册登陆连接的问题
如题.我是用PHP的.
<div>
<ul>
<?php
session_start();
echo $_SESSION['username'];
?>
<li>Login</li>
<li>Apply for user1</li>
<li>Apply for user2</li>
</ul>
</div>
------------以上是在index.php写的------------
我是想当登陆后.login , Apply for user1 , Apply for user2都不显示.只显示用户名和注销.
然后注销后就会显示回login , Apply for user1…….
求大神们教教我.
------解决方案--------------------
请给出index.php完整代码.
------解决方案--------------------
如题.我是用PHP的.
<div>
<ul>
<?php
session_start();
echo $_SESSION['username'];
?>
<li>Login</li>
<li>Apply for user1</li>
<li>Apply for user2</li>
</ul>
</div>
------------以上是在index.php写的------------
我是想当登陆后.login , Apply for user1 , Apply for user2都不显示.只显示用户名和注销.
然后注销后就会显示回login , Apply for user1…….
求大神们教教我.
------解决方案--------------------
请给出index.php完整代码.
------解决方案--------------------
- PHP code
<?php session_start(); ?> <ul> <?php if(!empty($_SESSION['username'])){?> <li>用户名<?php echo $_SESSION['username'];?></li> <li>注销</li> <?php }else{?> <li>Login</li> <li>Apply for user1</li> <li>Apply for user2</li> <?php }?> </ul>
------解决方案--------------------
------解决方案--------------------
<?php
session_start();
?>
<ul>
<?php if(!empty($_SESSION['username'])){?>
<li>用户名<?php echo $_SESSION['username'];?></li>
<li>注销</li>
<?php }else{?>
<li>Login</li>
<li>Apply for user1</li>
<li>Apply for user2</li>
<?php }?>
</ul>