更新时间:2023-12-04 09:12:46
< div id ='nav'>
<?php
if(is_logged_in())
{
if(is_admin())
{
echo anchor admin','Admin Dashboard');
}
echo anchor('user / logout','Logout');
echo anchor('users / profile','Profile'。'& nbsp; ['。$ _SESSION ['user_name']。']');
}
else
{
echo anchor('user / login','Login');
echo anchor('user / signup','Signup');
}
echo'& nbsp;'。 anchor(base_url(),'Home');
?>
< / div>
oK, since my original question didn't make sense to the majority, I will explain in details. I have a membership system I made through some tutorials based on codeigniter framework. on my main page I have 3 buttons containing login, register, forgot pass, respectively. when I test the login and enter my details as a user, I still can see the login button, which makes no sense because it should be hidden in case I logged in. The same thing for other features I mentioned above.
now I was trying some way like if($_SESSION['user'] == "")
{
to achieve my goal, but without any success.
any idea how to do this correctly?
Thanks
<div id='nav'>
<?php
if(is_logged_in())
{
if(is_admin())
{
echo anchor('admin','Admin Dashboard');
}
echo anchor('user/logout','Logout');
echo anchor('users/profile','Profile' . ' [' . $_SESSION['user_name'] . ']');
}
else
{
echo anchor('user/login','Login');
echo anchor('user/signup','Signup');
}
echo ' ' . anchor(base_url(),'Home');
?>
</div>