title: Multiple controllers in CakePHP
body: <p>I m new to cakephp...
        I m developing an app using CakePhp  and Mysql.
        In Cakephp i am  having two tables one is Form (id ,name,created , modified) and attributes (id, Attribute-name ,form_id ,value)
      I kept everything in only one controller that is in forms controller.Within this formsctrller , i m having actions like login ,register,viewforms...</p>
  
  <pre><code> Do i need to create a separate controller for login and register..If so Actually i will run in my system with http://localhost/cake/forms where i am having the place to register and login ...If i had separate controller,then how can i make that to switch from forms to login controller on login....Explain me...
  </code></pre>
  
  <p>Edit</p>
  
  <pre><code>&lt;?php
   class UsersController extends AppController 
  {
   var $name = 'Users';
  var $helpers=array('Html','Ajax','Javascript','Form');
   var $components = array( 'RequestHandler','Email');
   var $uses=array('Form','User','Attribute');
  //Function for login 
  function login()
     {
      $email_id=$this-&gt;data['User']['email_id'];
          $password=$this-&gt;data['User']['password'];
      $login=$this-&gt;User-&gt;find('all');
      $this-&gt;set('Forms',$this-&gt;Form-&gt;find('all'));
      foreach($login as $form):
          if($email_id==$form['User']['email_id'] &amp;&amp; $password==$form['User']['password'])
          {
              $this-&gt;Session-&gt;setFlash('Login Successful');
                              // $this-&gt;render('forms/homepage');
              $this-&gt;redirect('/forms/homepage');
  
  
              break;
          }
          else
          {
              $this-&gt;Session-&gt;setFlash('Login UnSuccessful');
              //$this-&gt;redirect('/forms/index');
          }
      endforeach;
  
  
  }
  
  //Function to register the user into Users Table.
  function register()
  {
             $this-&gt;set('Forms',$this-&gt;Form-&gt;find('all'));
      if (!empty($this-&gt;data)) 
      {
          if ($this-&gt;User-&gt;save($this-&gt;data)) 
          {
              $this-&gt;Session-&gt;setFlash('You have been registered.');
              $this-&gt;set('register', $this-&gt;Form-&gt;find('all'));
                              //$this-&gt;render('homepage');
              $this-&gt;redirect('/forms/homepage');
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Ya Now i am using two controllers One for Users and One for Forms .
  But One Doubt .I have run the above code..Actually in my /forms/index.ctp</p>
  
  <pre><code>      &lt;?php
       echo $javascript-&gt;link('prototype.js');
       echo $javascript-&gt;link('scriptaculous.js');
      echo $html-&gt;css('main.css');
     ?&gt;
  </code></pre>
  
  <p>
     <h2> formBuildr </h2>
    </p>
  
  <p>
   <h3>Register</h3></p>
  
  <pre><code>          &lt;?php
             echo $form-&gt;create('User',array('action'=&gt;'register'));
             echo $form-&gt;input('User.name');
            echo $form-&gt;input('User.email_id');
            echo $form-&gt;input('User.password');
             echo $form-&gt;end('Register');
            ?&gt;
     &lt;/div&gt;
  
       &lt;div id="login"&gt;
      &lt;h3&gt;Login&lt;/h3&gt;
          &lt;?php
                  echo $form-&gt;create('User',array('action'=&gt;'login'));
                  echo $form-&gt;input('User.email_id');
                  echo $form-&gt;input('User.password');
                  echo $form-&gt;end('Login');
           ?&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>I have registered and login ..It goes /forms/homepage But the thing is that ..It doesn't show me the Flash message Of (Login successfull/Unsucessfull) I tried with render option , but even showing me the error..
  Note :Since i no need to have anything in my views/users/login.ctp i am not having login.ctp..(SINCE I M LOGIN IN AND DIRECTLY MOVES TO HE HOMEPAGE OF MY FORMSCONTROLLER.</p>