class UserModel extends Model{
// 自动验证设置
protected $_validate = array(
array('mobile','require','手机号不能为空',1,'',3),
array('password','require','密码不能为空',1,'',4),
//array('mobile','User','手机号已经被注册',1,'unique',6),
);
//自动填充设置
// protected $_auto = array(
// array('regdate','time',self::MODEL_INSERT,'function'),
// array('password','md5',self::MODEL_INSERT,'function'),
// );
}public function userLogin(){
//判断是否有数据提交
if(!empty($_POST)){
//1.创建对象
$model = D("User");
//2.编写规则
//3.执行验证
if($model->create($_POST,4)){
$uid = $model->where('mobile="%s" and password="%s"',$_POST['mobile'],md5($_POST['password']))->getField('id');
$this->success('恭喜您,登录成功',U('User/homepage'));
}else{
$this->error($model->getError());
}
//4.登录或者报错
}
}直接就登录成功,我是初学者,帮忙看看吧 最佳答案