|
#view
<form action="<?=site_url()?>/category/insert" method="post">
<table border="0" cellpadding="2" cellspacing="1" style="width:100%">
<tr>
<td nowrap align="right" width="13%">上级栏目:</td>
<td width="41%"><select name="pid"><option value="0">≡ 作为一级栏目 ≡</option></select></td>
</tr>
<tr>
<td nowrap align="right" height="50px">栏目名称:</td>
<td colspan="3">
<input type="text" name="title" />
<?php echo form_error('title','<span class="form-error">','</span>'); ?>
</td>
</tr>
</table>
<input type="submit" value="提交" name="submit" class="inputbutton" />
<input type="button" name="submit2" value="返回" class="inputbutton" />
#controller
function insert()
{
$this->lang->load('form', 'chinese');
$this->load->library('form_validation');
$this->form_validation->set_rules('title', 'lang:form_title', 'trim|required');
if ($this->form_validation->run() === false)
{
$this->load->view('admin/addcate');
}
else
{
$this->load->model('admin/Category_model', '', true);
$this->Category_model->insert();
}
}
#model
function insert()
{
$this->title = $this->input->post('title');
$this->pid = $this->input->post('pid');
$this->db->insert('dj2_category', $this);
} |
|