Wasn't really sure how to title this question, but here it goes. I always use CodeIgntier's form validation class to validate my form information. In my application, there are forms that are used by other members that register. For example, if someone wants to post a comment on a blog article, they use the form for that article.
If my controller is:
class Blog extends CI_Controller {
function postcomment($blog_id){
if($this->form_validation->run('comment') == FALSE){
$this->parser->parse('comment_form.tpl', $data);
} else {
$this->blog_post->create_comment($blog_id);
}
}
}
and my model is...
class Blog_Post extends CI_Model {
function create_comment($blog_id){
$data = array(
'title' => $this->input->post('title'),
'content' => $this->input->post('content'),
'date' => time()
);
$this->db->insert('blog_comments', $data);
}
Is there a need to use preg_match, strlen, isset, etc, to validate the information before it's actually inserted?