Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to save data in CakePHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 611
    Comment on it

    This is a very simple application in cake php for saving the data into database. We can simple make it by making the database and connecting it to cake php.

    After making the database and tables we can use this code for saving the data input in form into database

    Pagecontroller.php

    <?php
    
        App::uses('AppController', 'Controller');
    
    
        class PagesController extends AppController {
    
    
          public $name = 'Pages';
          public $uses = array('SaveData');
    
          public $helpers = array('Js' => array('Jquery'));
    
    
            public function index() {
    
              if(!empty($this->data))
            {
              /* Save data code */
                    if($this->SaveData->save($this->data))
                    {
                        $this->Session->setFlash(__('Form data saved Successfully'));
    
                    }
                }
    
          }
    
    
        }
    

    form.ctp

    <?php echo $this->Session->flash(); ?>
    <?php echo $this->Form->create('SaveData');  ?>
    <?php echo $this->Form->input('name'); ?> 
    <?php echo $this->Form->input('email'); ?> 
    <?php echo $this->Form->input('city'); ?> 
    <?php echo $this->Form->end('Save Data'); ?> 
    

 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: