您当前的位置: 首页 > 学无止境 > 网站建设 网站首页网站建设
thinkphp-视图实例(会员登录)
发布时间:2015-12-18 13:31:22编辑:雪饮阅读()
建立登录模块
// 本类由系统自动生成,仅供测试用途
class LoginAction extends Action {
function index(){
$this->display();
}
function do_login(){
$username=$_POST["username"];
$password=$_POST["password"];
$code=$_POST["code"];
if($_SESSION["verify"]!==md5($code)){$this->error("验证码错误!");}
$m=M("User");
$where["username"]=$username;
$where["password"]=$password;
$i=$m->where($where)->count();
if($i>0){
$this->redirect("User/index");
}
else{
$this->error("用户信息有误");
}
}
}
登录视图模版:
<form action="__URL__/do_login" method="post">
用户名:<input type="text" name="username"/><br/>
密 码:<input type="password" name="password"/><br/>
验证码:<input type="text" name="code"/>
<img src="__APP__/Public/code" onClick='this.src=this.src+"?"+Math.random()'/>
<br/>
<input type="submit" value="登录"/>
</form>
验证码扩展库ThinkPHP3.1.2_Extend解压至Extend目录中
创建公共验证码模块:
// 本类由系统自动生成,仅供测试用途
class PublicAction extends Action {
function code(){
import('ORG.Util.Image');
Image::buildImageVerify();
}
}
数据库建立password字段,类型是char(md5加密是固定长度),长度32.
关键字词:thinkphp,视图,个人博客
上一篇:thinkphp-视图2(模版)
下一篇:thinkphp-模版变量