namespace Home\Controller;
use Think\Controller;
class RegController extends Controller {
public function index(){
$user=D('User');
if(!$user->create()){
$this->error($user->getError());
}
$lastId=$user->$add();
if($lastId){
$this->show('<script>alert("恭喜您,注册成功");window.history.go(-1);</script>');
}else{
$this->error('用户注册失败');
}
}
} namespace Home\Model;
use Think\Model;
class UserModel extends Model{
protected $_validate=array(
array('code','require','验证码必须填写!'),
array('code','check_verify','验证码错误!',0,'callback',1),
array('username','require','用户必须填写!'),
array('emali','require','邮箱必须填写!'),
array('username','','用户已经存在',0,'unique',1),
array('username','/^[a-zA-Z][a-zA-Z0-9]*$/','用户名第一个必须是字母',0,'regex',1),
array('username','/^\w{5,}$/','用户名至少5位字符',0,'regex',1),
array('emali','/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/','邮箱格式不正确',0,'regex',1),
array('repassword','password','确认密码不正确',0,'confirm'),
);
protected $_auto = array (
array('password','md5',1,'function'),
array('token_exptime','time()',1,'function'),
);
protected function check_verify($code, $id = ''){
$verify = new \Think\Verify();
return $verify->check($code, $id);
}
}这两段代码有何问题,都是按照手册上面写的啊注册提交的时候报错
最佳答案