How to get post data variables after submition a form in magento
You can get all variables using $this->getRequest()->getParams();
. This will return all variables. For any particular name like id
you can use $this->getRequest()->getParam('id');
without the "s". Hope this will help.
You can read the values with
$this->getRequest()->getParam('field_name');
The code above will get you values from GET
and POST
.
But if you want to check if something was sent specifically through POST
you can get it like this.
$this->getRequest()->getPost('field_name');
You can even specify a default value.
$somevar = $this->getRequest()->getParam('some_var', 7);
this means that if $_POST['some_var']
is not set, the variable $somevar
will have the value 7
.