首页 > 作文

TP5框架简单登录功能实现方法示例

更新时间:2023-04-08 07:56:35 阅读: 评论:0

本文实例讲述了tp5框架简单登录功能实现方法。分享给大家供大家参考,具体如下:

登录方法,验证

public function login(){    if(request()->isget()){      return view('login');    }elif(request()->ispost()){      $model = new infomodel();       $name = input('name'); //获取表单提交的姓名      $pwd = input('password');//获取表单提交的密码      if($model->loginverify($name,$pwd)){        $verify = input('code'); //获取验证码的值        $cap = new captcha(); //实例化验证码类        if($c服务质量管理制度ap->check($verify)){          $this->success('登录成功','admin/showindex');//登录成功跳转首页          /*echo '登录成功';*/        }el{          $this->error('验证码错误','admin/admin/login');        }      }    }}

表单

<div class="form-group">    <div class="field field-icon-right">      <input type="password" class="input input-big" name="password" placeholder="登录密码" data-validate="required:请填写密码" />边城沈从文;      <span class="icon icon-key margin-small"></span>    </div>  </div>  <div class="form-group">    <div class="field">      <input type="text" class="input input-big" name="code" placeholder="填写右侧的验证码" data-validate="required:请填写右侧的验证码" />      <img src="{:captcha_src()}" alt="" width="150" height="32" class="passcode" style="height:43px;cursor:pointer;" οnclick="this.src=this.src+'?'">     </div></div>

model类,要与表名同名

<?phpnamespace app\admin\model;u think\model;class info extends model{#登录验证  public function loginverify($name,$pwd)  {    //$re = $this->where(["urnam唱歌有什么好处e =>'$name',pwd=唱歌咬字>'$pwd'"])->find();    $re = $this->where("urname='$name' and pwd='$pwd'")->find();    if($re){      return $re;    }el{      retu欧式电视背景墙rn null;    }  }}

本文发布于:2023-04-08 07:56:33,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/1f54d2602441491a2663900b8773fad1.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:TP5框架简单登录功能实现方法示例.doc

本文 PDF 下载地址:TP5框架简单登录功能实现方法示例.pdf

标签:验证码   表单   密码   请填写
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图