public function ask_question()
 {
     $data['message'] = "";
     $data['username'] = $this->session->userdata('username');
     $this->form_validation->set_rules('title', 'Title', 'trim|required|max_length[100]|xxs_clean');
     $this->form_validation->set_rules('body', 'Details', 'trim|required|max_length[4000]|xxs_clean|htmlspecialchars');
     $this->form_validation->set_rules('tags', 'Tags', 'trim|required|max_length[100]|xxs_clean');
     if ($this->form_validation->run() == TRUE && isset($_POST['submit']) == TRUE) {
         $qstn = new Ask_qstn_model();
         $qstn->title = $this->input->post('title');
         $qstn->body = $this->input->post('body');
         $qstn->tag1 = $this->input->post('tags');
         $qstn->userid = $this->session->userdata('userid');
         $qstn->username = $this->session->userdata('username');
         date_default_timezone_set("Asia/Kolkata");
         $date = new DateTime();
         $qstn->time = $date->getTimestamp();
         if ($qstn->insert_qstn()) {
             $data['message'] = "Question succeessfully submited";
             $this->load->helper('url', $data);
             $this->load->view('user/header/header_ask', $data);
             $this->load->view('user/ask_question', $data);
             $this->load->view('footer/footer', $data);
         }
     }
     $this->load->view('user/header/header_ask', $data);
     $this->load->view('user/ask_question', $data);
     $this->load->view('user/sidebar/right_sidebar', $data);
     $this->load->view('footer/footer', $data);
 }
 public function insert_qstn()
 {
     $this->db->trans_start();
     $this->db->query("insert into qstns values (default,\"" . $this->title . "\",\"" . $this->body . "\")");
     $q_id = Ask_qstn_model::get_qid($this->title);
     $this->db->query("update qinfo set time=" . $this->time . ",tag1='" . $this->tag1 . "',tag2=default,tag3=default,tag4=default,tag5=default where qid=" . $q_id);
     $this->db->query("update qu set uid='" . $this->userid . "' where qid=" . $q_id);
     $this->db->query("insert into qu values(" . $q_id . "," . $this->userid . ")");
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         return FALSE;
     } else {
         return TRUE;
     }
 }