php - CodeIgnitor how to give action url for view page -


i have codeginitor system displaying products. when products view page executed through url

localhost/project/index.php/product/view/102 

i want add option add comment particular product in page, how can give

$data['action'] = site_url('product/prodcutview'); 

this have tried far, didn't save value , tihnk action url not correct, please advice.

function addcomment() {      // set common properties     $data['title'] = 'add new comment';     $data['action'] = site_url('/product/productview');       // set empty default form field values     $this -> _set_fields();     // set validation properties     $this -> _set_rules();      // run validation     if ($this -> form_validation -> run() == false) {           log_message('debug', 'comment save failed.');      } else {         // save data         $comment = array(         'product_id' => $this -> input -> post('product_id'),          'comment' => $this -> input -> post('comment'),           'review' => $this -> input -> post('review'),           );         $category_id = $this -> comment_model -> save($comment);       }      // load view     $this -> load -> view('/product/productview', $data); } 

you try using uri segments make sure site url link correct , matches have in url.

localhost/project/index.php/product/view/102 

testing echo out $this->uri->segment(3) , see number shows.

if ($this->uri->segment(3) == false) {   $data['action'] = site_url('product/view'); } else {   $data['action'] = site_url('product/view') .'/'. $this->uri->segment(3); } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -