[eluser]victor76[/eluser]
Hi,
I got his blog post form in my View dir:
Code:
<form name="postit" action="http://localhost/codeIgniter/index.php/blog_controller/dopost" method="post">
title: <input type="text" name="title" id="title" /><br />
comment: <input type="text" name="comment" id="comment" /><br />
<input type="submit" value="send" />
</form>
In my Controller I have:
Code:
function doPost()
{
$this->load->model('Blogmodel','',TRUE);
$data['query'] = $this->Blogmodel->insert_entry();
}
..And in my Model:
Code:
function insert_entry()
{
$this->title = $_POST['title'];
$this->content = $_POST['comment'];
$this->date = time();
$this->db->insert('entries', $this);
}
When I post my form, I get the error:
Quote:Error Number: 1054
Unknown column '_parent_name' in 'field list'
INSERT INTO entries (title, content, date, _parent_name, _ci_scaffolding, _ci_scaff_table) VALUES ('aaa', 'bla', 1193057963, 'Blogmodel', 0, 0)
...so, as a Newbie I can see i miss some columns in my DB (_parent_name, etc), but how can I fix my code so that it just inserts 'title','comment' and 'date'?
Best regards,
Vic
======================
I found it allready:
perhaps usefull for others...
Code:
function insert_entry()
{
$title = $_POST['title'];
$comment = $_POST['comment'];
$aData = array('title' => $title, 'content' => $comment);
$this->db->insert('entries', $aData);
}
Is this the best way to insert data from a form, or is there a better way?
Best regards,
Vic