简体   繁体   中英

how to get parameter POST or GET and showing in controller with FuelPHP framework

i'm having problem when i want to get Parameter value from method POST or GET in FuelPHP framework my question

1) that is same with $_GET['params'] or $_POST['params'] ? if same i think i will do something to secure that, i hope any automatically function to secure post and get parameter from fuelphp framework , any someone is know?

2) how i can show that parameter in controller? i just try using like this

       /*
        * for getting request param for client and save to database
        */
       public function action_input(){
        echo Input::post('name');                                                                                                                                                 
        }

but i'm get error like this

Fuel\Core\FuelException [ Error ]: The controller action called or it's after() method must return a Response object.

how i can fix that ?

thanks you for your helping.

http://docs.fuelphp.com/classes/input.html

<?php echo Input::post('foo') ?>

where "foo" is your POSTed parameter.

Either use a "View" (as suggested above in the comments) to display your response or do the following in your controller action.

return new Response(Input::post(<your_parameter_here>));

The primary reason is as quoted in the documentation.
http://docs.fuelphp.com/general/controllers/base.html

"A controller action MUST return a Response object. Optionally you can specify special HTTP headers, or a custom HTTP status code (a code other than "200 OK").

If your controller extends one of the base controllers, your action can also return any value that can be cast to string, like for example a View object. The after() method of the base controller will convert it into a Response object for you.

If your controller does not extend one of the base controllers, and you want to use this feature, your controller must contain it's own after() method that will accept the actions return value, and has to wrap it into a Reponse object which it must return. "

请看看fuelPHP中的POST方法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM