[eluser]dancrew32[/eluser]
I threw in some pseudocode in comments() because I'm not particularly sure how to do form_open('movie/comments'); and trigger some kind of conditional statement to run through insert_comment($data).
Code:
function comments()
{
$data['title'] = 'Comments List';
$data['comments'] = $this->Movie_model->fetchRow($this->uri->segment(3), 'movie_id', 'movie_comments');
if post is detected {
// Data Input
$data['comment'] = $this->input->post('comment', TRUE); // XSS Filtered?
$data['author'] = $this->input->post('author', TRUE);
$data['movie_id'] = $this->input->post('movie_id', TRUE);
insert_comment($data);
}
$this->load->view('front/movie_comment_view', $data);
}
private function insert_comment($data)
{
$this->form_validation->set_rules('comment', 'Comment', 'required|min_length[1]|max_length[100]|xss_clean|prep_form');
$this->form_validation->set_rules('author', 'Author', 'required|min_length[1]|max_length[40]|xss_clean|prep_form');
if ($this->form_validation->run() == FALSE) {
$this->load->view('front/movie_comment_view', $data);
} else {
$this->Movie_model->insertRow('movie_comments', $data);
redirect('movie/comments/'. $data['movie_id']);
}
}
Sorry for noobin ya..