Hello,
I try to input this form:
Parent Categories
PARENT NAME [ Men ]
DESCRIPTION [ Description ]
[ SUBMIT ]
Parent Categories
The Category Parent Name field is required.
The Category Parent Description field is required.
PARENT NAME [ ]
DESCRIPTION [ ]
[ SUBMIT ]
After I press submit button. That error message appearing. I wonder why? Can anyone help me read the codes to fix the result. I expect a success message instead.
views/addparentctg.php
PHP Code:
<div class="widget-box">
<div class="widget-title"><h5>Parent Categories</h5></div>
<div class="widget-content">
<?php $this->load->library('form_validation'); ?>
<?php echo validation_errors(); ?>
<?php echo form_open('cpages/addparentctgcreate'); ?>
<table border="0" style="width: 80%; height: 90px;">
<tr>
<td>PARENT NAME</td>
<td><input type="text" name="ctgparent_name"></td>
</td>
<tr>
<td>DESCRIPTION</td>
<td><input type="text" name="ctgparent_description"></td>
</td>
<tr>
<td></td>
<td><input type="submit" class="edit" name="submit" value="SUBMIT" /></td>
</td>
</table>
</form>
</div>
</div>
controllers/cpages.php
PHP Code:
public function addparentctgcreate() {
$this->form_validation->set_rules('ctgparentname', 'Category Parent Name', 'required');
$this->form_validation->set_rules('ctgparentdescription', 'Category Parent Description', 'required');
if($this->form_validation->run() === FALSE)
{
$this->load->view('addparentctg');
}
else
{
$this->Mpages->set_parentctg();
$this->load->view('addparentctgsuccess');
}
}
Models/Mpages.php
PHP Code:
public function set_parentctg()
{
$data = array(
'ctgparent_name' => $this->input->post('ctgparent_name'),
'ctgp_no' => $this->input->post('ctgp_no'),
'ctgparent_description' => $this->input->post('ctgparent_description')
);
return $this->db->insert('menu', $data);
}
" If I looks more intelligence please increase my reputation."