时间:2021-07-01 10:21:17 帮助过:4人阅读
3. 控制器调用,建立driver控制器
public function add() { $this->load->model(‘driver_model‘,‘drv‘); $data = array( ‘name‘ => $this->input->get(‘name‘), ‘telphone‘ => $this->input->get(‘telphone‘), ‘car‘ => $this->input->get(‘car‘), ‘idcard‘ => $this->input->get(‘idcard‘), ‘content‘ => $this->input->get(‘content‘) ); $this->drv->add($data); }
4. 建立view视图
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>driver add</title> </head> <body> <form action="driver/add" > <table> <th> <tr></tr> <tr>添加司机</tr> </th> <tr> <td>姓名:</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>手机:</td> <td><input type="text" name="telphone" /></td> </tr> <tr> <td>身份证:</td> <td><input type="text" name="idcard" /></td> </tr> <tr> <td>车辆</td> <td><input type="text" name ="car"/></td> </tr> <tr> <td>备注;</td> <td><input type="text" name="content" /></td> </tr> <tr> <td></td> <td><input type="submit" /></td> </tr> </table> </form> </body> </html>
----------------------------------------
走过的弯路,在输入安全类中,将input->get , 输入成input->post
第二个是,从admin的总的控制器中,跳转时,跳转路径不正常,重写的路由规则,在config里router文件中,添加如下规则,否则跳转时,控制器的url片段上,有admin的总控制器的名字。
$route[‘admin/([a-z]+)/([a-z]+)‘] = ‘/$1/$2‘;
CI 笔记 数据库
标签: