Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Lost POST data when routed
  • If i acess a page through a route from my routes.php the POST data gets lost.

    If i direct acess the controller the POST data is available.
    What am i doing wrong i want to use routes.php?

    Tia
       John
  • HarroHarro
    Accepted Answer
    Huh?

    If that wouldn't work, my guess is that 99% of all Fuel apps don't work. So something else must be going on..

    Which version are you on? How do you route? And how do you access your post data?


  • Hi Harro,

    Thats also my idea, i must be doing something very stupid.

    This is my routes.php line:
    '(\w{2})/socialMedia/facebookLink' => 'socialMedia/facebookLike',

    And my function in the socialMedia controller:
     public function post_facebookLike()
        {
            $inputData = \Input::param();
            print_r($inputData);exit;
    }

    It's filled when i comment out the route otherwise it returns the route 
    (Array ( [/nl/socialMedia/facebookLink] => ))

    My version is 1.5 

  • Hi Harro,

    Problem solved.
    The headers where wrong so no $_POST data was received at all.
    I tried firstline in index.php and even there $_POST was empty.

    After changing the curl class in fuel (we use curl to access REST layer) everything worked.

    protected function method_post()
    {
    $params = is_array($this->params) ? $this->encode($this->params) : $this->params;

    $this->set_option(CURLOPT_POST, true);
    $this->set_option(CURLOPT_POSTFIELDS, $params);
    $this->set_header('application/x-www-form-urlencoded');  <--- ADDED LINE
    }



Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion