如何使用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();
}
}表单部分
以上就是如何使用thinkPHP实现一个验证码登录功能,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。
当前题目:如何使用thinkPHP实现一个验证码登录功能-创新互联
网页路径:http://jxruijie.cn/article/ddjpjj.html
