<?php
class Login extends CFormModel
{
public $username;
public $password;
public $k='kalpit';
public function login()
{
if($this->username== $this->k)
{
var_dump("hi");
return true;
}
else
{
var_dump("sorry");
return false;
}
}
public function rules()
{
return array(
array('username,password','required')
);
}
}
LoginController.php
<?php
class LoginController extends Controller
{
public function actionLoginForm()
{
var_dump("hi");
$model = new Login();
if($model->login())
{
var_dump("hi");
//$this->redirct('site/index');
}
else
{
var_dump("sorry");
}
$this->render('site/loginForm',array('model'=>$model));
}
}
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->login()){
//$this->redirect(CController::createUrl('customer/index'));
$this->redirect(CController::createUrl('customer/index/tab'));
return;
}else{
Yii::app()->user->setFlash('error',Yii::t("messages",'Invalid email or password'));
$this->redirect('login');
Yii::app()->end();
}
}
it’s not showing any error… and it’s not calling controller only… i am printing var_dump() inside actionLoginForm() but it’s not printing anything. so it’s not calling controller only…
and in model it’s calling rules() but not calling login() method… (this is because i am calling login() method from controller so.