thinkphp无法自动验证问题

浏览:1071 发布日期:2015/09/02 分类:求助交流 关键字: thinkphp, 自动验证
<?php

class CenterModel extends Model{

//protected $patchValidate = true;

protected $_validate=array(
array('users','require','用户名不能为空!'),
array('users','','用户名已经存在',0,'unique',1),
array('password','require','密码不能为空!','md5'),
array('passwords','password','两个密码必须一致','0','confirm'),
);

}
?>
这是模型部分
public function regg(){
//添加到数据表
$center_model = D('center');

if(!empty($_POST)){
dump($_POST);
$z = $center_model->create();
//$this->success('注册成功',U('Index/Regg/regg1'));
if($z){

$ret = $center_model->add();
if($ret){

echo 'ok';
}else{
echo 'failure';

}

}else{

dump($center_model->getError());

}
}else{

$this->display();

}
}
这是控制器部分
现在就是空提交,就输出ok
而不是 用户名不能为空! 这个提示语句?
最佳答案
评论( 相关
后面还有条评论,点击查看>>