Welcome Guest, Not a member yet? Register   Sign In
Can not run $this->input->post('inputName'); in Modular Extensions
#1

[eluser]greedyman[/eluser]
As my title, I tried call that method but I got an error:
Quote:Fatal error: Call to a member function post() on a non-object in C:\xampp\htdocs\cifirst\application\modules\front\controllers\shopping.php on line 11
If I create a controller not in module, that method I can use very easy but in this case can not. This is my code:
Code:
// everything can not use
public function add_to_cart() {
  $data = array(
   'id' => $this->input->post('productId'),
   'name' => $this->input->post('productName'),
   'price' => $this->input->post('productPrice'),
   'qty' => 1,
   'options' => array('img' => $this->input->post('productImg'))
  );
  
  $this->load->library('MY_Cart');
  $this->cart->insert($data);
  
  //redirect($_SERVER['HTTP_REFERER']);
  //echo $_POST['productId'].'-'.$_POST['productName'];
}
And this code doesn't work too:
Code:
public function __construct() {
  $this->load->library('cart');
  $this->load->helper('form');
}
I'm using XAMPP 1.8.1, CodeIgniter 2.1.3 and newest MX. Please help me!
#2

[eluser]Cgull[/eluser]
How do you declare your controller? e.g. class Shopping extends MX_Controller?
Which line of your code is line 11?
#3

[eluser]greedyman[/eluser]
[quote author="Cgull" date="1373969853"]How do you declare your controller? e.g. class Shopping extends MX_Controller?
Which line of your code is line 11?[/quote]

Line 11 is $this->input->post('productId'). My problem is resolved, I don't declare path to my module yet. Thank for your comment.




Theme © iAndrew 2016 - Forum software by © MyBB