i am new to yii… this is my first form…
i have created a simple login form using user model (user table)…
which validates the user name and password from database and direct user to its own page… (ex: if admin, to admin’s page) like wise.
the problem is, on submitting the form with keeping blanks (for both user and pass field) it display error messages
as defined in USER model class… for example… i have defined as, username and password is required…
array(‘user_name, user_pass’, ‘required’, ‘on’=>‘loginn’)
so those errors are being displayed if the form is empty submitted.
but when wrong values are given, it validates properly… but doesn’t show any error message as username or password entered is not correct or not found.
but, when i use set flash message as error or notice… its displayed… (this way i dont want it to be )
below given is my login action… please let me know what i made as mistake.
if(isset($_POST[‘Users’]))
{
$model->attributes=$_POST['Users'];
if($model->validate() && $model->login())
{
//if($this->validateUser($_POST['Users']['user_name'],$_POST['Users']['user_pass'])){
$this->redirect('test');
}
else {
Yii::app()->user->setFlash('error', "username or password is incorrect");
}
}