search
HomeBackend DevelopmentPHP TutorialNavigation bar processing before and after login 2015-12-12, navigation bar 2015-12-12_PHP tutorial

Note: add gray background, about ajax value transfer, and js Judgment

1 Controller processing after login: determine whether to log in and transfer user information

<span>class</span> IndexController <span>extends</span><span> HomeBaseController {
    </span><span>//</span><span>登录</span>
    <span>public</span> <span>function</span><span> index() {
        </span><span>$id</span>=I("get.id"<span>);      
        </span><span>$users_model</span>=M("Users"<span>);        
        </span><span>$user</span>=<span>$users_model</span>->where(<span>array</span>("id"=><span>$id</span>))-><span>find();      
        </span><span>if</span>(<span>empty</span>(<span>$user</span><span>)){
            </span><span>$this</span>->error("查无此人!"<span>);
        }
        </span><span>$this</span>->assign(<span>$user</span><span>);
        </span><span>$this</span>->display(":index"<span>);
    }
    </span><span>function</span><span> is_login(){
        </span><span>if</span><span>(sp_is_user_login()){
            </span><span><span>$this</span>->ajaxReturn(<span>array</span>("status"=>1,"user"=></span><span><span>sp_get_current_user()));</span>
        }</span><span>else</span><span>{
            </span><span>$this</span>->ajaxReturn(<span>array</span>("status"=>0,"info"=>"此用户未登录!"<span>));
        }
    }<br />。。。。。。</span>

2 Login and non-login display in the homepage navigation bar before and after login

<span><</span><span>div </span><span>id</span><span>="main-menu-user"</span><span>></span>
      <span><!--</span><span>还未登陆</span><span>--></span>
            <span><</span><span>div  </span><span>class</span><span>='userout </span><span>user' </span><span>></span>
                <span><</span><span>ul </span><span>class</span><span>="nav navbar-nav  navbar-right"</span><span>></span>
                    <span><</span><span>li</span><span>></span>
                        <span><</span><span>a </span><span>href</span><span>="{:u('user/register/index')}"</span><span> data-toggle</span><span>="dropdown"</span><span>></span>注册<span></</span><span>a</span><span>></span>
                    <span></</span><span>li</span><span>></span>
                <span></</span><span>ul</span><span>></span>
                <span><</span><span>ul </span><span>class</span><span>="nav navbar-nav  navbar-right"</span><span>></span>
                    <span><</span><span>li</span><span>></span>
                        <span><</span><span>a </span><span>href</span><span>="{:u('user/login/index')}"</span><span>  data-toggle</span><span>="dropdown"</span><span>></span>登陆<span></</span><span>a</span><span>></span>
                    <span></</span><span>li</span><span>></span>
                <span></</span><span>ul</span><span>></span>
                <span><</span><span>ul </span><span>class</span><span>="nav navbar-nav  navbar-right"</span><span> style</span><span>="margin-top:10px"</span><span>></span>
                    <span><</span><span>li </span><span>></span>
                        <span><</span><span>img </span><span>src</span><span>="__TMPL__/Public/img/headicon.png"</span><span> class</span><span>="headicon"</span><span>/></span>
                    <span></</span><span>li</span><span>></span>
                <span></</span><span>ul</span><span>></span>
            <span></</span><span>div</span><span>></span>
    <span><!--</span><span>已经登陆</span><span>--></span>
            <span><</span><span>div </span><span>class</span><span>="userlogin user"</span> <span>></span>
                <span><</span><span>ul </span><span>class</span><span>="nav navbar-nav  navbar-right"</span><span>></span>
                    <span><</span><span>li</span><span>></span>
                        <span><</span><span>a </span><span>href</span><span>="{:u('user/index/logout')}"</span><span> data-toggle</span><span>="dropdown"</span><span>></span>退出<span></</span><span>a</span><span>></span>
                    <span></</span><span>li</span><span>></span>
                <span></</span><span>ul</span><span>></span>
                <span><</span><span>ul </span><span>class</span><span>="nav navbar-nav  navbar-right"</span><span>></span>
                    <span><</span><span>li</span><span>></span>
                 <span><</span><span>a </span><span>href</span><span>="{:u('user/center/index')}"</span><span>  data-toggle</span><span>="dropdown"</span><span> class</span><span>="user-nicename"</span><span>></</span><span>a</span><span>></span>
                    <span></</span><span>li</span><span>></span>
                <span></</span><span>ul</span><span>></span>
                <span><</span><span>ul </span><span>class</span><span>="nav navbar-nav  navbar-right"</span><span> style</span><span>="margin-top:10px"</span><span>></span>
                    <span><</span><span>li </span><span>></span>
                        <span><</span><span>img </span><span>src</span><span>=""</span><span> class</span><span>="headicon"</span><span>/></span>
                    <span></</span><span>li</span><span>></span>
                <span></</span><span>ul</span><span>></span>
            <span></</span><span>div</span><span>></span>
<span></</span><span>div</span><span>></span>

3 After logging in, js operation on the box

<script><br /><span> $(</span><span>function</span><span> () {</span><span>/*</span><span>控制导航栏显示登陆还是个人中心</span><span>*/</span><span>
  $.post(</span>"{:U('user/index/is_login')}",{},<span>function</span><span>(data){
      </span><span>if</span>(data.status==1<span>){
          </span><span>if</span><span>(data.user.avatar){
<span>              $(</span></span><span>"#main-menu-user ul li .headicong").attr("src",data.user.avatar.indexOf("http")==0?data.user.avatar:"__UPLOAD__avatar/"+<span>data.user.avatar);
            }
      $(</span>"#main-menu-user ul li .user-nicename").text(data.user.user_nicename!=""?</span><span><span>data.user.user_nicename:data.user.user_login);</span>
      $(</span>"#main-menu-user .userlogin"<span>).show();
      $(</span>"#main-menu-user .userout"<span>).hide();               
      }
      </span><span>if</span>(data.status==0<span>){
         $(</span>"#main-menu-user .userout"<span>).show();
         $(</span>"#main-menu-user .userlogin"<span>).hide();
      }
});  });
</span></script>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1080771.htmlTechArticleNavigation bar processing before and after login 2015-12-12, navigation bar 2015-12-12 Note: Add gray background , about ajax value transfer, and js judgment 1. Controller processing after login: judge whether to log in and pass...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PlayStation网络登录失败,但互联网连接成功PlayStation网络登录失败,但互联网连接成功Feb 19, 2024 pm 11:33 PM

一些玩家在PS4或PS5发布时遇到了一个奇怪的问题。例如,当他们的PlayStation网络登录失败,但互联网连接正常时,这可能会引起困扰。在输入登录信息时,可能会遇到错误,而且可能无法加入PSParty聊天。如果你遇到了类似问题,这个指南可能会帮助你解决。在PlayStationNetworkSign-in旁边,你会看到错误信息‘AnErrorHaveAreAre’,它会显示‘Failure’。其他参数如获取IP地址、互联网连接和连接速度都是成功的。那么,这里的问题可能是什么呢?我会给你工作的

修复AADSTS7000112,应用程序被禁用Microsoft帐户登录错误修复AADSTS7000112,应用程序被禁用Microsoft帐户登录错误Feb 19, 2024 pm 06:27 PM

AADSTS7000112错误可能会阻止您使用Microsoft帐户登录应用程序,给您带来不便。本文将为您提供解决方案,帮助您解决这个问题,恢复正常的登录体验。登录:很抱歉,您登录时遇到问题。AADSTS7000112:应用程序已禁用。幸运的是,您可以遵循一些简单的建议来修复错误。错误代码AADSTS7000112是什么?错误代码AADSTS7000112表示与Microsoft的AzureActiveDirectory连接出现问题。通常情况下,这可能是由于尝试登录的Microsoft应用程序被

GeForce Experience登录死机[修复]GeForce Experience登录死机[修复]Mar 19, 2024 pm 06:30 PM

本文将指导您解决在Windows11/10上出现的GeForceExperience登录死机问题。通常情况下,这可能是由于不稳定的网络连接、损坏的DNS缓存、过时或损坏的图形卡驱动程序等原因引起的。修复GeForceExperience登录黑屏在开始之前,请确保重新启动您的互联网连接和计算机。有时候,这个问题可能只是由于临时问题引起的。如果您仍然遇到NVIDIAGeForceExperience登录黑屏问题,请考虑采取以下建议:检查您的internet连接切换到另一个Internet连接禁用您的

企业微信的邮箱怎么登陆企业微信的邮箱怎么登陆Mar 10, 2024 pm 12:43 PM

企业微信的邮箱怎么登陆?企业微信APP中是可以登陆邮箱,但是多数的用户不知道邮箱如何的登陆,接下来就是小编为用户带来的企业微信邮箱登陆方法图文教程,感兴趣的用户快来一起看看吧!企业微信使用教程企业微信的邮箱怎么登陆1、首先打开企业微信APP,进入到主页面最底部【工作台】点击来专区;2、之后在工作台专区中,选择其中的【企业邮箱】服务;3、然后跳转到企业邮箱功能页,点击底部的【绑定】或者【换一个邮箱】;4、最后在下图所示的页面输入【QQ账号】和【密码】即可登陆邮箱。

Wegame登陆操作过于频繁怎么解决?Wegame登陆操作过于频繁怎么解决?Mar 14, 2024 pm 07:40 PM

  Wegame是一款搭配腾讯游戏使用的软件,可以通过它来启动游戏,获得加速,而近期有不少用户在使用的时候出现了登陆操作过于频繁的提示,面对这个提示,许多用户都不知道怎么才能够成功解决,那么本期软件教程就来和大伙分享解决方法,一起来了解看看吧。  Wegame登陆操作过于频繁怎么办?  方法一:  1、首先确认一下我们的网络连接是否正常。  (可以尝试打开浏览器,看看能不能上网)  2、如果是网络故障,那么尝试重启路由器、重连网线、重启电脑来解决。  方法二:  1、如果网络没有问题,那么选择&

足球导航语音包在哪个导航软件足球导航语音包在哪个导航软件Nov 09, 2022 pm 04:33 PM

足球导航语音包在“高德导航”软件中,是高德地图车机版导航语音包的其中一种,内容为黄健翔足球解说版本的导航语音。设置方法:1、打开高德地图软件;2、点击进入“更多工具”-“导航语音”选项;3、找到“黄健翔热血语音”,点击“下载”;4、在弹出的页面,点击“使用语音”即可。

百度地图 App 最新版本 18.8.0 发布,首次引入红绿灯雷达功能,并新增实时停车推荐功能百度地图 App 最新版本 18.8.0 发布,首次引入红绿灯雷达功能,并新增实时停车推荐功能Aug 06, 2023 pm 06:05 PM

百度地图App安卓版/iOS版均已发布18.8.0版本,首次引入红绿灯雷达功能,业内领先据官方介绍,开启红绿灯雷达后,支持开车自动探测红绿灯,不用输入目的地,北斗高精可以实时定位,全国100万+红绿灯自动触发绿波提醒。除此之外,新功能还提供全程静音导航,使图区更简洁,关键信息一目了然,且无语音播报,使驾驶员更加专注驾驶百度地图于2020年10月上线红绿灯倒计时功能,支持实时读秒预判,导航会在接近红绿灯路口时,自动展示倒计时剩余秒数,让用户时刻掌握前方路况。截至2022年12月31日,红绿灯倒计时

win7系统登陆时的默认图片背景如何更改win7系统登陆时的默认图片背景如何更改Jun 30, 2023 pm 04:03 PM

  win7系统登陆时的默认图片背景如何更改?win7系统登陆时的默认图片背景如何更改教程分享。我们电脑设置了登陆密码之后,开启电脑之后到登陆界面的时候,就会有一个图片背景。有的用户想要去修改这个背景,那么如何操作才能去修改这个背景呢?很多小伙伴不知道怎么详细操作,小编下面整理了win7系统登陆时的默认图片背景更改步骤,如果你感兴趣的话,跟着小编一起往下看看吧!  win7系统登陆时的默认图片背景更改步骤  1、首先在图示路径C:WindowsSystem32oobeinfoackgrounds

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.