数据库及其表格为utf8_general_ci
控制器:
function add()
{
if ($this->input->server('REQUEST_METHOD') === 'POST')
{
$this->form_validation->set_rules('question', 'question', 'required');
$this->form_validation->set_rules('answer', 'answer', 'required');
$this->form_validation->set_error_delimiters('<br /><em class="error">', '</em>');
if ($this->form_validation->run() == FALSE) // valf_idation hasn't been passed
{
}
else // passed valf_idation proceed to post success logic
{
$form_data = array(
'question' => set_value('question'),
'answer' => set_value('answer')
if ($this->Faq_model->setClientData($form_data) == TRUE)
{
$this->session->set_flashdata('flash_message', 'Client Saved Successfully');
$this->session->set_flashdata('flash_type', 'success');
}
else
{
$this->session->set_flashdata('flash_message', 'Oops Error Occured While Saving Client');
$this->session->set_flashdata('flash_type', 'error');
}
redirect('admin/faq');
}
}
$data['main_content'] = 'admin/faq/add';
$this->load->view('includes/template', $data);
}