[eluser]bakpakka[/eluser]
I'm impressed the forum is so active, keep it up! If I could seek some assistance from the CI whizzes, it would be appreciated.
I currently have a blog script that displays an article with the ability the submit comments below. After posting a new comment, the validate class can return an error if a field is not filled. It will the repopulate any completed fields.
What if it was a successful transaction? I return the user to the article page, but do not want the fields repopulated. What can I do? Here's a snippet of code.
Thanks, all.
Code:
// Load up validation library, rules and fields
$this->load->library('validation');
$rules['comment'] = $rules['name_person'] = "trim|required";
$this->validation->set_rules($rules);
$fields['name_person'] = "Name";
$fields['comment'] = "Comment";
$this->validation->set_fields($fields);
// Validation is passed, store in db
if ($this->validation->run() == TRUE)
{
$insert_db = array('date_created'=>date('Y-m-d H:i:s'), 'article_id'=>$article_id, 'created_by'=>'1', 'status'=>'active', 'name_person'=>htmlspecialchars($_POST['name_person']), 'content'=>htmlspecialchars($_POST['comment']));
$this->db->insert('articles_comments', $insert_db);
$row['success_msg'] = "Your comment has been posted";
// Stop the repopulation of data, then return to the view
}
$template['content'] = $this->load->view('articles/article_view', $row, true);
$this->load->view('themes/moo/article', $template);