ThinkPHP实现登录退出功能

前端之家收集整理的这篇文章主要介绍了ThinkPHP实现登录退出功能前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例为大家分享了ThinkPHP实现登录退出功能的具体代码,供大家参考,具体内容如下

PHP;"> check($yzm)){//调用check方法 return true; }else{ echo '验证码错误'; exit(); } }

public function login(){
if(!IS_POST){
$this->display();
}else{
//若验证码验证通过
if($this->checkyzm(I('post.yzm'))){
$username=I('post.username');
$user=D( ' user ' )->where(" username='$username' ")->find();
//post过来的password拼接盐md5后密码=数据库的密码,则通过
if(md5( I( ' post.password ' ) . $user[ ' salt ' ])===$user['password']{
cookie('username',$userp[ ' username ' ]);//写入cookie
$this->redirect('/');//跳转首页
}else{
echo '用户名或密码不对';
}
}
}
}

/**V层

  • 退出登陆
  • 读取cookie $Think.cookie
    */
    //若没有cookie数据
    您好欢迎观临
    <if condition="$Think.cookie.username eq null">
    <a href="{:U('Home/User/login')}" rel="external nofollow" rel="external nofollow" style="color:#50884b">登陆 |
    <a href="{:U('Home/User/reg')}" rel="external nofollow" style="color:#50884b">免费注册 | {$Think.cookie.username}| <nofollow" rel="external nofollow" style="color:#50884b">退出

/**

?>}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

原文链接:https://www.f2er.com/thinkphp/17213.html

猜你在找的ThinkPHP相关文章