I'm passing a search data on method GET like that:
example.com/posts/?q=foo
I'm trying retrive this data on controller doing this:
$this->params['q'];
but is not working.
Looks like you're using CakePHP 1.3. If the submission was made using Cake's Form Helper, it should be something like..
$this->params['data']['q']
or if you explicitly wrote your own HTML code for the form,
$this->params['url']['q']
CakePHP specifice function for accessing query strings:
$this->request->query['q'];
Reference: Link .
CakePHP has simple helpers that let you access parameters.
For GET
parameters you can use:
/users/search?age=23
$this->request->query['age']; // 23
For POST
parameters you can use:
$this->request->data('age'); // 23
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.