dongtan2603 2015-11-08 15:17
浏览 19
已采纳

将用户定向到所需的页面

i have installed yii user and rights and upon login through "webapp/user/login" it directs me to the index.php page. i want to direct admin to another page rather then index.php page. which file would i need to edit to direct admin to the desired page. Help needed.

  • 写回答

1条回答 默认 最新

  • dpqjvoq9033 2015-11-08 16:28
    关注

    you should have this code in you site/controller

    /**
     * Displays the login page
     */
    public function actionLogin()
    {
        $model=new LoginForm;
    
        // 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['LoginForm']))
        {
            $model->attributes=$_POST['LoginForm'];
            // validate user input and redirect to the previous page if valid
            if($model->validate() && $model->login())
               // 
               //this if you want redirect to returnUrl (index.php by default) 
               // here you can change redirect to url you prefer 
               // or render proper page  
               // $this->redirect(Yii::app()->user->returnUrl);
               // this for your destination 
                $this->redirect(array('story/create'));
        }
        // display the login form
        $this->render('login',array('model'=>$model));
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?