用户登录时隐藏注册和登录按钮? [英] Hide registration and login buttons when a user logged in?

查看:171
本文介绍了用户登录时隐藏注册和登录按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我原来的问题对大多数人没有意义,我会详细解释。我有一个会员制度,我通过一些基于codeigniter框架的教程。在我的主页我有3个按钮包含登录,注册,忘记通过,分别。当我测试登录和输入我的详细信息作为用户,我仍然可以看到登录按钮,这没有任何意义,因为它应该隐藏的情况下,我登录。同样的事情,对于上面提到的其他功能。



现在我正在尝试某种方式像 if($ _ SESSION ['user'] ==)
{
实现我的目标,但没有任何成功。



任何想法如何正确地做?



感谢

解决方案

 < 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' . '&nbsp;[' . $_SESSION['user_name'] . ']');

}
else
{
    echo anchor('user/login','Login');
    echo anchor('user/signup','Signup');                        
}

echo '&nbsp;' . anchor(base_url(),'Home');
?>

</div>

这篇关于用户登录时隐藏注册和登录按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆