Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to register new user using cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 196
    Comment on it

    For storing new user information in database, first we have to  create a new table in database which contain user name,email,password fields.

    The logic of the controller is written below. In below code we have create a function registration ,so we have to create a view with similar name with .ctp extension. View will contain our registration form which will send  user information to the controller by using POST method.

    <?php 
    App::uses('Controller','Controller');
    
    class UsersController extends AppController 
    {     
            function registration(){
    
             
            if ($this->request->is('post')) { // checking form data is send by using post 
               
                $this->User->create(); //  function will save the data  of the user in the database 
               
                if ($this->User->save($this->request->data)) {
                    $this->Session->setFlash(__('The user has been created'));
                    $this->redirect(array('action' => 'login'));
                } else {
                    $this->Session->setFlash(__('The user could not be created. Please, try again.'));
                }   
            }
        }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: