Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to edit user information in cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 483
    Comment on it

    For editing user information in cake php by clicking on edit button we have to first pass user id in URL by using below code in our view.

    <?php echo $this->Html->link('Edit',array('action'=>'edit/'.$user['User']['id'])); 
    		         

    And we have to put the following code in that function where we will wright code for editing data in our controller.

     public function edit($id = null){
             
           
            $user = $this->User->findById($id); //getting user information on the bases of id which we are passing
            
           if ($this->request->is('post')) {
    
              
                if ($this->User->save($this->request->data)) {
                    $this->Session->setFlash(__('The user has been updated'));
                    $this->redirect(array('action' => 'display', $id));
                  }
                   
                else{
                    $this->Session->setFlash(__('Unable to update your user.'));
                }
            }
    
            if (!$this->request->data) {
                $this->request->data = $user;
            }
        }
    

     

 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: