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)