Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/vajra.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Talk_with_experts extends Admin_Controller { function __construct() { parent::__construct(); } //this is to list all wishlist public function index() { $this->data['questions'] = $this->db->select('*')->from('talk_to_experts')->order_by('id','DESC')->get()->result(); //load view $this->data['subview'] = 'admin/talk_with_expert/index'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } function edit($id){ //check if id exist. If not exist, show 404. $count = $this->db->select('id')->from('talk_to_experts')->where('id',$id)->get()->row()->id; if ($count == 0) { show_404(); } $this->data['answer'] = $this->db->select('*')->from('talk_to_experts')->where('id',$id)->get()->row(); //validation check in action $config = array( array( 'field' => 'answer_by', 'label' => 'Your Name', 'rules' => 'trim|required' ), array( 'field' => 'answer_title', 'label' => 'Answer Title', 'rules' => 'trim|required' ), array( 'field' => 'answer', 'label' => 'Your Answer', 'rules' => 'trim|required' ), ); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run($this) == TRUE) { $data = array( 'answer_by' => $this->security->xss_clean($this->input->post('answer_by')), 'answer_title' => $this->security->xss_clean($this->input->post('answer_title')), 'answer_alias' => url_title($this->security->xss_clean($this->input->post('answer_title'))), 'answer' => $this->security->xss_clean($this->input->post('answer')), 'answer_date' => date("Y-m-d"), 'answer_status' => 'answered', ); $this->db->where('id',$id); $this->db->update('talk_to_experts',$data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Answering Question Successful</p>'); redirect('admin/talk_with_experts'); } $this->data['subview'] = 'admin/talk_with_expert/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } function delete($id){ //check if id exist. If not exist, show 404. $count = $this->db->select('id')->from('talk_to_experts')->where('id',$id)->get()->row()->id; if ($count == 0) { show_404(); } $this->db->where('id',$id); $this->db->delete('talk_to_experts'); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Deleting Question Successful</p>'); redirect('admin/talk_with_experts'); } }