Jump to content
Larry Ullman's Book Forums

mrs

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by mrs

  1. Hi, After click on activation link http://www.example.com/devtest/index.php?r=user/check&activationcode=bc74873d0e3f684d3e6b99a36169a793ee688406 then it redirect to login page. I think my following controller code not working for view file check.php which located on user directory. public function actionCheck() { $model=new User; $activationcode = Yii::app()->request->getQuery('activationcode'); if(isset($activationcode)) { $model = User::model()->findByAttributes(array('activationcode'=>$activationcode)); if($model !== null) { $model->status=1; $model->save(); Yii::app()->user->setFlash('check','Thank you for register with us'); $this->refresh(); } } $this->render('check',array( 'model'=>$model, )); } I am not sure how I can handle GET URL action in UserController. Also, I already tested by adding word 'check' in accessRules but then browser show me Page not redirect properly. public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index','create','view','captcha'), 'users'=>array('*'), ), ..... ..... ); } Any idea? Please give me a idea about how I can solve this. With Thanks, MRS
  2. Hi All, I am facing problem to activate an user by click on activation link that sent by email. Here is my code- UserController.php: public function actionCreate() { $model=new User; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if(isset($_POST['User'])) { $model->attributes=$_POST['User']; $model->createtime=date('Y-m-d H:i:s'); $model->activationcode = sha1(mt_rand(10000, 99999).time().$model->email); if($model->save()) { $to = $model->email; $subject = "Welcome To My Site!" $message2 = "<html> <body>Please click this below to activate your membership<br />". Yii::app()->createAbsoluteUrl('user/check', array('activationcode' => $model->activationcode))." Thanks you </body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: My Site < admin@mysite.com>' . "\r\n"; mail($to,$subject,$message2,$headers); $this->redirect(array('view','id'=>$model->id)); } } $this->render('create', array('model'=>$model)); } public function actionCheck() { $activationcode = Yii::app()->request->getQuery('activationcode'); // collect user input data if(isset($activationcode)) { $model = User::model()->find('activationcode=:activationcode', array(':activationcode'=>$activationcode)); if($activationcode == $model->activationcode) { $model->status=1; //$model->validate(); $model->save(); Yii::app()->user->setFlash('check','Thank you for register with us'); $this->refresh(); } } // display the login form $this->render('check',array('model'=>$model)); } View file check.php: <?php if(Yii::app()->user->hasFlash('check')): ?> <div class="flash-success"> <?php echo Yii::app()->user->getFlash('check'); ?> </div> <?php endif; ?> I am not sure why activation link not working. After click on activation link then status not changed to 1 in database. Also, the page redirect to create view page. I was testing by adding 'check' in rules but then page stopped to redirect. I need quick help. With thanks, MRS
×
×
  • Create New...