Hello! I am starting with yii framework I am programming in version 1.9 and what I try to do is that my main page is the login, and when a user is logged in I redirect to the project forms with their permissions of each user

this is my login code:


/* @var $this SiteController */

/* @var $model LoginForm */

/* @var $form CActiveForm  */



body h1{










	top: -20px;

	left: -20px;

	right: -40px;

	bottom: -40px;

	width: auto;

	height: auto;


	background-image: url(fondo.jpg);

	background-size: cover;





<font color="White">


<div class="form-horizontal">

<?php $form=$this->beginWidget('CActiveForm', array(






	'action' => array("site/login"),

    )); ?>


<div class="control-group">

		<?php echo $form->labelEx($model,'username', array('class'=>'control-label')); ?>

		<div class="controls">

			<?php echo $form->textField($model,'username'); ?>

	    	<?php echo $form->error($model,'username'); ?>



	<div class="control-group">

		<?php echo $form->labelEx($model,'password', array('class'=>'control-label')); ?>

		<div class="controls">

			<?php echo $form->passwordField($model,'password'); ?>

			<?php echo $form->error($model,'password'); ?>





	<div class="control-group ">

		<div class="controls">

         	<?php echo CHtml::submitButton('Login', array('class'=>'btn btn-primary')) ?>

		     <a href="#" class="facebook_connect radius button facebook"><i class="fa fa-facebook-square"></i>			



<?php $this->endWidget(); ?>

</div><!-- form -->

and this is my SiteController:

public function actionLogin()



		$model=new LoginForm;

		// if it is ajax validation request

		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')


			echo CActiveForm::validate($model);



		// collect user input data




			// validate user input and redirect to the previous page if valid

			if($model->validate() && $model->login());



		// display the login form



In advance thanks for the help

What’s the question?

how can I do so that by clicking the login button I redirected to a form or another page?

All you need is to set redirection url (one that you want user to redirect). Something like :

if($model->validate() && $model->login());



1 Like

thank you very much :D