应用程序/控制器/ CarrierController.php
这里我插入数据库表但没有插入并显示无法添加您的详细信息
数据库表字段id(自动增量),fname,lname,dob,字段,性别
class CarrierController extends AppController {
public $helpers = array('Html', 'Form', 'Session');
public $components = array('Session');
var $uses=array('Carrier');
public function index(){
// $this->set('posts', $this->carrier->find('all'));
if($this->request->is('post')){
Configure::read();
pr($this->data);
$this->Carrier->create();
if ($this->Carrier->save($this->request->data)) {
$this->Session->setFlash(__('Your Details has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('Unable to add your Details'));
}
}
}
}
应用程序/视图/运营商/ index.ctp
<h1>welcome to Carriers</h1>
<br />
<br/>
<?php echo $this->Form->create('Carriers', array('enctype' => 'multipart/form-data'));?>
<table>
<tr><h3>Register here</h3></tr>
<tr><td>F.Name</td><td><?php echo $this->Form->text('fname'); ?></td></tr>
<tr><td>L.Name</td><td><?php echo $this->Form->text('lname');?></td></tr>
<tr><td>Date Of Birth</td><td><?php echo $this->Form->date('dob');?></td></tr>
<tr><td>Degree</td><td><?php echo $this->Form->select('field', array('options' => array('B.E','B.sc','Mca','Mtech','Mba'),'empty' => '(choose)')); ?></td></tr>
<tr><td>Sex</td><td><?php
$options=array('M'=>'Male','F'=>'Female');
$attributes=array('legend'=>false);
echo $this->Form->radio('gender',$options,$attributes);
?></td></tr>
<tr><td><?php echo $this->Form->input('Carriers.Resume', array('between'=>'<br />','type'=>'file'));?></td></tr>
<tr><td><?php echo $this->Form->end('Apply');?></td></tr>
</table>
应用程序/模型/ Carrier.php
<?php
class Carrier extends AppModel{
public $useTable='carrier'; //this is table name fields are inserted
}
?>