Login Issue

Hello there,

I have a pretty strange issue with login functionality.

When user submits the page after typing in username & password, the result is always an error saying [color="#FF0000"]Password cannot be blank.[/color]

When i debug the code, i found that the $_POST[‘LoginForm’] from the actionLogin is having only user name.

[color="#0000FF"]Array ( [LoginForm] => Array ( [username] => admin ) [yt0] => Login ) [/color]

Can anybody help me out Why [color="#0000FF"][LoginForm][/color] Array doesn’t storing other two field values [color="#0000FF"]password & rememberMe[/color]

The Application is working fine in dev server.

And when its pushed to Prod Server, i am facing this issue.

I need to Fix this ASAP.

Thanks in advance

It is almost impossible to find the cause of your problem without the code…

Are you sure those attributes exists in your model? Maybe your tables are missing the columns because you forgot to run the migrations on the production server?

Use Firebug to inspect the rendered HTML and check names in the <input> tags.


please check this your model,controller name and view name if your server is linux may be case-sesitive issue so please check it.

Hi guys,

thanks for the response.

the out from print_r($_POST) is [color="#0000FF"]Array ( [LoginForm] => Array ( [username] => admin ) [yt0] => Login )[/color]

rest of things are perfectly in place.

Now, my suspect is got onto PHP version, i never thought the issue with Yii Framework.

[color="#FF0000"]NOTE:[/color] The same code working on dev server and on other PROD SERVER. fortunately the PHP Ver is same on both the ends (PHP Ver 5.3.10)

When we moved the same code Amazon Cloud Server, facing this issue.

PROD Cloud SERVER PHP version => 5.3.8

Need Help.


Was the issue sorted…i am having the same issue.

not able to post multiple values on php 5.3.8 for yii




Please share your model, view and controller code.

Find the code below


<div class="form">

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






)); ?>

&lt;p class=&quot;note&quot;&gt;Fields with &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; are required.&lt;/p&gt;

&lt;div class=&quot;row&quot;&gt;

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'username'); ?&gt;

	&lt;?php echo &#036;form-&gt;textField(&#036;model,'username'); ?&gt;

	&lt;?php echo &#036;form-&gt;error(&#036;model,'username'); ?&gt;


&lt;div class=&quot;row&quot;&gt;

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'password'); ?&gt;

	&lt;?php echo &#036;form-&gt;passwordField(&#036;model,'password'); ?&gt;

	&lt;?php echo &#036;form-&gt;error(&#036;model,'password'); ?&gt;

	&lt;p class=&quot;hint&quot;&gt;

		Hint: You may login with &lt;kbd&gt;demo&lt;/kbd&gt;/&lt;kbd&gt;demo&lt;/kbd&gt; or &lt;kbd&gt;admin&lt;/kbd&gt;/&lt;kbd&gt;admin&lt;/kbd&gt;.



&lt;div class=&quot;row rememberMe&quot;&gt;

	&lt;?php echo &#036;form-&gt;checkBox(&#036;model,'rememberMe'); ?&gt;

	&lt;?php echo &#036;form-&gt;label(&#036;model,'rememberMe'); ?&gt;

	&lt;?php echo &#036;form-&gt;error(&#036;model,'rememberMe'); ?&gt;


&lt;div class=&quot;row buttons&quot;&gt;

	&lt;?php echo CHtml::submitButton('Login'); ?&gt;


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




public function actionLogin()


	&#036;model=new LoginForm;

	// if it is ajax validation request

	if(isset(&#036;_POST['ajax']) &amp;&amp; &#036;_POST['ajax']==='login-form')


		echo CActiveForm::validate(&#036;model);



	// collect user input data




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

		if(&#036;model-&gt;validate() &amp;&amp; &#036;model-&gt;login())



	// display the login form





class LoginForm extends CFormModel


public &#036;username;

public &#036;password;

public &#036;rememberMe;

private &#036;_identity;


 * Declares the validation rules.

 * The rules state that username and password are required,

 * and password needs to be authenticated.


public function rules()


	return array(

		// username and password are required

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

		// rememberMe needs to be a boolean

		array('rememberMe', 'boolean'),

		// password needs to be authenticated

		array('password', 'authenticate'),




 * Declares attribute labels.


public function attributeLabels()


	return array(

		'rememberMe'=&gt;'Remember me next time',




 * Authenticates the password.

 * This is the 'authenticate' validator as declared in rules().


public function authenticate(&#036;attribute,&#036;params)




		&#036;this-&gt;_identity=new UserIdentity(&#036;this-&gt;username,&#036;this-&gt;password);


			&#036;this-&gt;addError('password','Incorrect username or password.');




 * Logs in the user using the given username and password in the model.

 * @return boolean whether login is successful


public function login()




		&#036;this-&gt;_identity=new UserIdentity(&#036;this-&gt;username,&#036;this-&gt;password);





		&#036;duration=&#036;this-&gt;rememberMe ? 3600*24*30 : 0; // 30 days


		return true;



		return false;




There is not any problem regarding your code… Your code is almost right. It may be problem regarding PHP version or Yii version. I could not find any problem in your code…