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/indolok.id/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Product_review extends Public_Controller { public function __construct() { parent::__construct(); } public function add_review() { if(!isset($_POST['submit_review'])) { show_404(); } if($this->session->userdata('customer')['customer_id'] != NULL) { //check if this product_id and customer_id already reviewed... $this->db->select('product_id, customer_id') ->from('product_review') ->where('Product_id', $this->input->post('product_id')) ->where('customer_id', $this->session->userdata('customer')['customer_id']); $count_review = $this->db->get()->num_rows(); if($count_review == 0) { //review not yet...can proceed.. $data = array( 'product_id' => $this->input->post('product_id'), 'customer_id' => $this->session->userdata('customer')['customer_id'], 'rating' => $this->input->post('rating'), 'review' => $this->security->xss_clean($this->input->post('review')), 'subject' => $this->security->xss_clean($this->input->post('subject')) ); $this->db->insert('product_review', $data); $this->session->set_flashdata('product_review', '<p style="color:green"><strong>ULASAN BERHASIL DITAMBAHKAN</strong><br><br></p>'); } else { //review already... $this->session->set_flashdata('product_review', '<p style="color:green"><strong>ANDA SUDAH PERNAH MENGULAS PRODUK INI</strong><br><br></p>'); } redirect('product/' . $this->input->post('product_alias')); } } }