Login And Register In Same Page

Hi, I need login page and register page in only one page.

My login is in site/login and register is in user/create. Now i add renderPartial in my sitr/login, then it showing like this

"SiteController cannot find the requested view "_form".

Try adding a fwd slash and path.


<?php echo $this->renderPartial('/path/to/_form', array('model' => $model)); ?>

Same error?

Can any one help me, how to come out from this problem.

Can i know How to retrive data into database from site/login.

Hi Deva,

Can you please elaborate a bit more regarding what are you trying to do?

What kind of data you want retrieve from database (or save to database)?

Regards,

Leandro

Dear sir,

           In site/login page i added register form fields. so, when i click register the data needs to store in database. Actuall i need both login and register page in same page.

Hi Deva,

If you need combine login and register pages in one page, maybe this could help: http://www.yiiframework.com/forum/index.php/topic/20163-login-and-register-forms-in-the-same-page/.

Regards,

Leandro

The reason is because the /user/create has a renderPartial in it that simply calls to _form. Since you are within the site controller rather than the user controller, Yii is looking for _form in the site views. It should be looking for it in the user views though. In the site/login, change your renderPartial to this:


<?php echo $this->renderPartial('//user/_form', array('model' => $model)); ?>

Dear sir, If i use this render partial profile update is displaying in my login page. But, register page i’m not getting. Pls help me.

It’s not working. My login action in site/login and my register action in user/create. By using renderPartial i call login page into register page, but when login with username and password the register fields also asking, that is the problem.

NOw i’m getting both login and register pages in my //path/to/user/create location.And here my register fields and register button is working. But, my login fields are not working. i.e., when i enter username and password it also asking register fields also when click login button.

Hi, can i know how to make different actions in one page. Actuall in user/create file i had added one more file. In user/create file having two files like login and register. When i click login button it asking register fields also. I think the page is not seperated. In PHP we will get separate actions in same page for login and register. When i tried in yii i’m getting error. Pls help me. Thank you.

You wrote "I think the page is not seperated", but separated from what?

In user/create is working for only Register page. When i enter username and password for login and when i click login it asking register fields also.

I called site/login by using renderPartial into user/create. Here user/create is taking entire page functionality for only Register.

You need to check that Are you creating forms for different actions?

Also, with your problem, sharing code will be helpful

Thanks

Hi Deva,

Can you please post your code?

Regards,

Leandro

[color="#FF0000"]/* NOTE: DO NOT POST THE SAME ISSUE IN DIFFERENT THREADS, PLEASE. */[/color]

Hi Deva,

According to the code that you have attatched to one of the other posts of yours, your login page has 2 forms.

http://www.yiiframework.com/forum/index.php/topic/43263-sitecontroller-cannot-find-the-requested-view-form

The code goes like this … I’ve cut it down to the minimun.

There are 2 problems here.

  1. You are supplying the LoginForm model to the 2nd form that should deal with the User model.

  2. You are not responding to the submission of the 2nd form.

So a kind of the following should work, I hope. :)




// controller : SiteController.php

public function actionLogin()

{

    $model = new LoginForm;

    // collect user input data for Login Form

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

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

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

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

            ...

        }

    }

    $userModel = new User;

    // collect user input data for User Form

    if (isset($_POST['User'])) {

        $userModel->attributes = $_POST['User'];

        // validate user input and save ...

        if ($userModel->save()) {

            ...

        }

    }

    // display the login page

    $this->render('login', array('model' => $model, 'userModel' => $userModel));

}






// view : login.php

...

<?php echo $this->renderPartial('/user/create', array('model' => $userModel)); ?>



Can any one help me. In my user/create page both login and register pages is having, but, login part is not working when i click login button it asking register fields also required.

Hi, here is my problem in SiteController

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);


		Yii::app()-&gt;end();


	}





	// collect user input data


	if(isset(&#036;_POST['LoginForm']))


	{


		&#036;model-&gt;attributes=&#036;_POST['LoginForm'];


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


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


			&#036;this-&gt;redirect(Yii::app()-&gt;user-&gt;returnUrl);


	}


	// display the login form


	&#036;this-&gt;render('login',array('model'=&gt;&#036;model));





&#036;model=new UserMember;


	


	if(isset(&#036;_POST['UserMember']))


	{


		&#036;model-&gt;attributes=&#036;_POST['UserMember'];


		if(&#036;model-&gt;save())


			&#036;this-&gt;redirect(array('view','id'=&gt;&#036;model-&gt;id_user));


	}





	&#036;this-&gt;render('create',array(


		'model'=&gt;&#036;model,


	));





}.

Can i know where i did mistake.