thinkPHP实现的验证码登录功能示例
(编辑:jimmy 日期: 2025/12/27 浏览:3 次 )
本文实例讲述了thinkPHP实现的验证码登录功能。分享给大家供大家参考,具体如下:
使用thinkphp自带的验证,实现登录页面的账号密码+验证码的验证
<"'.$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();
}
}
表单部分
<form action="login" method="post"> <table valign="top" width="50%"> <tr><td colspan="2"><h4 style="letter-spacing:1px;font-size:16px;">RainMan 网站管理后台</h4></td></tr> <tr><td>管理员:</td><td><input type="text" name="user_name" value="" /></td></tr> <tr><td>密 码:</td><td><input type="password" name="password" value="" /></td></tr> <tr><td>验证码:</td> <td><input type="text" name="yanzhengma" value="" style="width:80px;"/></td> <td><img src="/UploadFiles/2021-04-02/verifyImg">更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》及《PHP模板技术总结》。
希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。
下一篇:thinkPHP实现上传图片及生成缩略图功能示例