Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //session_start();
- class LoginController extends Controller{
- public function actionIndex(){
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- //$this->render('_viewLogin');
- $model=new Login;
- $this->render('_viewLogin',array('model'=>$model));
- }
- public function actionError(){
- if($error=Yii::app()->errorHandler->error){
- if(Yii::app()->request->isAjaxRequest)
- echo $error['message'];
- else
- $this->render('error', $error);
- }
- }
- public function actionLogin(){
- $model=new Login;
- // if it is ajax validation request
- if(isset($_POST['ajax']) && $_POST['ajax']==='login-form'){
- echo CActiveForm::validate($model);
- Yii::app()->end();
- }
- // collect user input data
- if(isset($_POST['Login'])){
- $model->attributes=$_POST['Login'];
- // validate user input and redirect to the previous page if valid
- if($model->validate() && $model->login())
- //$this->redirect(Yii::app()->user->returnUrl);
- $this->render('_viewLogin',array('model'=>$model));
- }
- //print_r($model);
- $this->render('_viewLogin',array('model'=>$model));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement