webyjh 2012-01-06 10:30:19 3331次浏览 2条回复 0 0 0

如下代码:???号处的应该如何赋值呢?

public function actionCreate() {
    $model = new Users('create');
    // Uncomment the following line if AJAX validation is needed
    $this->performAjaxValidation($model);

    if (isset($_POST['Users'])) {
        $model->attributes = $_POST['Users'];
        $model->pwd=md5($model->pwd);//将密码加密后存储
        $model->pwd2=md5($model->pwd2);
        if ($model->save())
            yii::app()->user->username=$model->username;//???
            yii::app()->user->id=$model->id;//???
            Yii::app()->user->setState('identity','user');//设为已登录                
            $this->redirect(array('site/index'));
        }
        $this->render('create', array(
            'model' => $model,
        ));
}
  • 回复于 2012-01-06 13:40 举报
    if(Yii::app()->user->isGuest)
        echo CHtml::link('登录',array('userss/login')); 
    else
        echo CHtml::link('注销('.Yii::app()->user->name.')',array('userss/logout')); 
    
  • 回复于 2012-01-06 15:28 举报

    可能是我说得不清楚,
    通常用户注册好后都是跳转到登录页面,我是想让用户注册成功后直接显示登录成功,并把用户登录成功后的标志赋值
    比如:身份信息,用户名等

您需要登录后才可以回复。登录 | 立即注册