[eluser]Shiva666[/eluser]
Hi
I'm trying to insert data into my database using a form and active records, but for some reason after I add a record and I check my database two rows have been inserted. One has nothing in it while the other one has the data that I entered.
This is my content controller
Quote:function content_create() {
$data = array(
'title' => $this->input->post('title'),
'content' => $this->input->post('content'),
'meta_title' => $this->input->post('meta_title'),
'meta_description' => $this->input->post('meta_description'),
'meta_keywords' => $this->input->post('meta_keywords')
);
$this->load->model('mdl_content');
$this->mdl_content->create($data);
$data['view_file'] = "create";
$this->load->module('templates');
$this->templates->ci_admin($data);
}
This is my model
Quote:function get_table() {
$table = "content";
return $table;
}
function create($data) {
$table = $this->get_table();
$page_url = url_title($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'content' => $this->input->post('content'),
'page_url' => $page_url,
'meta_title' => $this->input->post('meta_title'),
'meta_description' => $this->input->post('meta_description'),
'meta_keywords' => $this->input->post('meta_keywords')
);
return $this->db->insert($table, $data);
return;
}
and this is the view
Quote: <h2>Create</h2>
<?php
echo form_open('content/content_create');
?>
<p>
<label for="title">Title:</label>
<input type="text" name="title" id="title" />
</p>
<p>
<label for="content">Content:</label>
<input type="text" name="content" id="content" />
</p>
<p>
<label for="meta_title">Meta_Title:</label>
<input type="text" name="meta_title" id="meta_title" />
</p>
<p>
<label for="meta_description">Meta_Description:</label>
<input type="text" name="meta_description" id="meta_description" />
</p>
<p>
<label for="meta_keywords">Meta_Keywords:</label>
<input type="text" name="meta_keywords" id="meta_keywords" />
</p>
<input type="submit" value="Submit" />
<?php
echo form_close();
?>