Advertisement
Guest User

loginController

a guest
Sep 16th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. <?php
  2. //session_start();
  3. class LoginController extends Controller{
  4. public function actionIndex(){
  5. // renders the view file 'protected/views/site/index.php'
  6. // using the default layout 'protected/views/layouts/main.php'
  7. //$this->render('_viewLogin');
  8. $model=new Login;
  9. $this->render('_viewLogin',array('model'=>$model));
  10. }
  11. public function actionError(){
  12. if($error=Yii::app()->errorHandler->error){
  13. if(Yii::app()->request->isAjaxRequest)
  14. echo $error['message'];
  15. else
  16. $this->render('error', $error);
  17. }
  18. }
  19. public function actionLogin(){
  20. $model=new Login;
  21. // if it is ajax validation request
  22. if(isset($_POST['ajax']) && $_POST['ajax']==='login-form'){
  23. echo CActiveForm::validate($model);
  24. Yii::app()->end();
  25. }
  26. // collect user input data
  27. if(isset($_POST['Login'])){
  28. $model->attributes=$_POST['Login'];
  29. // validate user input and redirect to the previous page if valid
  30. if($model->validate() && $model->login())
  31. //$this->redirect(Yii::app()->user->returnUrl);
  32. $this->render('_viewLogin',array('model'=>$model));
  33. }
  34. //print_r($model);
  35. $this->render('_viewLogin',array('model'=>$model));
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement