empty login page.

Hi all.

the problem is next. When I try to open login page (index.php?r=site/login) I see the empty page.

the code was copy-pasted from official yii tutorial. So there aren’t any mistakes.

If delete this in SiteController: if(isset($_POST[‘loginForm’])) I see part of my view file for login page. What did I do incorrectly?

There must be some error… but you have to show as "your" code… so that we can help you…

mdomba here is the code:

SiteController.php


<?php


class SiteController extends CController

{

    .....

	

	public function actionLogin()

	{

	    $form  = new LoginForm;

	    if (isset($_POST['LoginForm']))

	    {

		$form->attributes=$_POST['LoginForm'];

		if($form->validate())

	        $this->redirect(Yii::app()->user-returnUrl);

		$this->render('login', array('user'=>$form));

	    } 

	}

     .....

}



LoginForm.php


<?php


class LoginForm extends CFormModel

{

    public $username;

    public $password;

    public $rememberMe=false;


    public function rules()

    {

	return array(

	    array('username, password', 'required'),

            array('rememberMe', 'boolean'),

            array('password', 'authenticate'),

        );

    }

    

    public function authenticate($attribute, $params)

    {

	if(!$this->hasErrors())

        {

    	    $identity = new UserIdentity($this->username, $this->password);

    	    if($identity->authenticate())

    	    {

    		$duration=$this->rememberMe ? 3600*24*30 : 0;

    		Yii::app()->user->login($identity, $duration);

    	    }

            else

        	$this->addError('password', 'Invalid password.');

        }

    

    }





}

login.php




<h1>Login page</h1>


<div class="form">

<?php $form=$this->beginWidget('CActiveForm'); ?>

 

    <?php echo $form->errorSummary($model); ?>

 

    <div class="row">

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

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

    </div>

 

    <div class="row">

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

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

    </div>

 

    <div class="row rememberMe">

        <?php echo $form->checkBox($model,'rememberMe'); ?>

        <?php echo $form->label($model,'rememberMe'); ?>

    </div>

 

    <div class="row submit">

        <?php echo CHtml::submitButton('Login'); ?>

    </div>

 

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

</div>






        public function actionLogin()

        {

            $form  = new LoginForm;

            if (isset($_POST['LoginForm']))

            {

                $form->attributes=$_POST['LoginForm'];

                if($form->validate())

                    $this->redirect(Yii::app()->user-returnUrl);

            }

            $this->render('login', array('user'=>$form));

        }



andy_s thanks :)

So it was not exactly a copy/paste… :)