thinkPHP实现的验证码登录功能示例

2018-06-22 00:58:46来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

本文实例讲述了thinkPHP实现的验证码登录功能。分享给大家供大家参考,具体如下:

使用thinkphp自带的验证,实现登录页面的账号密码+验证码的验证

check(I('post.yanzhengma','','trim'))){
          // 注释部分为另外一种从数据库中验证密码的方法
          // $data['name'] = I('post.user_name');
          // $data['psd'] = I('post.password');
          // $row = M('user')->where($data)->find();
          $name = I('post.user_name');
          $psd = I('post.password');
          $str = 'name ="'.$name. '" and tel = "'.$psd.'"';
          var_dump($str);
          $row = M('user')->where($str)->find();
          if($row)
            $this->redirect("Index/index");
          else
            $this->redirect('login','',1,'用户名或密码错误');
        }
        else{
          $this->redirect('login','',1,'验证码错误');
        }
      }
      $this->display();
    }
    public function verifyImg(){
      //设置验证码的宽高字体大小以及验证码的个数,设计其他的参照Think\Verify里面的设置
      $config=array(
        'imageW'  => 150,
        'imageH'  => 40,
        'fontSize' => 20,
        'length'  => 4
      );
      $obj = new \Think\Verify($config);
      $obj->entry();
    }
  }

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:PHP常见数学运算函数以及bc高精度函数的功能与使用技巧

下一篇:分享php两个多维数组组合遍历的实例