您好,欢迎访问一九零五行业门户网

有关Yii框架表单验证的有关问题懂Yii的大神请进来看看吧.

有关yii框架表单验证的问题。懂yii的大神请进来看看吧...
我在用yii做一个简单的小blog,在做后台登陆验证的时候,出现bug,
不提示登陆错误信息,我做的是账号,密码,验证码不能为空。
而且也不与数据库匹配。我已经测试过,数据库连接完全没有问题。
logincontroller.php
attributes = $_post['loginform'];
if($loginform->validate()){
echo 1;die;
}
}
$this->render('index',array('loginform' => $loginform));
}
public function actions(){
return array(
'captcha' => array(
'class' => 'system.web.widgets.captcha.ccaptchaaction',
'height' => 25,
'width'  => 80,
'minlength' => 4,
'maxlength' => 4,
'offset' => 3,
'padding' => 1
),
);
}
}
这个是model,user.php
 '用户名不能为空'),
array('password', 'required', 'message' => '密码不能为空'),
// rememberme needs to be a boolean
array('rememberme', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
//自定义错误信息
array('captcha', 'captcha', 'message' => '验证码错误'),
);
}
这个是输出错误信息的页面  index.php
error($loginform,'username') ?>
error($loginform,'password') ?>
error($loginform,'captcha') ?>
这个是components目录中的  useridentity.php
find('username = :name', array(':name' => $this->username));
if($userinfo == null){
$this->errorcode = self::error_username_invalid;
return false;
}
if($userinfo->password !== md5($this->password)){
$this->errorcode = self::error_password_invalid;
return false;
}
$this->errorcode = self::error_none;
return true;
}
}
到底哪里出错了,数据库链接已经测过,完全没有问题。
现在的情况是,即使写了错误信息,也不提示,也不执行登陆验证。除了验证码可以更换之外,完全就像一个静态页面。
------解决方案--------------------
if(isset($_post['$loginform'])){ ???
是 if(isset($_post['loginform'])){ 吧
其它类似信息

推荐信息