How to get post data variables after submition a form in magento

前端 未结 5 1379
暖寄归人
暖寄归人 2021-01-31 20:39

How do I get data of post variables ? Like if I post form with post method then I can get itt with $_REQUEST or with $_POST. How I can do this in mgento ?

相关标签:
5条回答
  • 2021-01-31 21:00

    You can go through this way:

    replace 'ship-note' with your custom field.

    $delivery_instruction_note = Mage::app()->getRequest()->getParam('ship-note');
    
    0 讨论(0)
  • 2021-01-31 21:07

    Just to mention for everyone looking into this thread..

    $this->getRequest()->getParams('value_here');
    

    is just wrong... The only available method to retrieve a special param with or without default value is without s

    $this->getRequest()->getParam('param','defaultValue');
    

    All other comments are just wrong

    0 讨论(0)
  • 2021-01-31 21:10

    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.

    0 讨论(0)
  • 2021-01-31 21:11

    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.

    0 讨论(0)
  • 2021-01-31 21:14

    Return array with params post/get

    Mage::app()->getRequest()->getParams();
    

    Return value by field name

    Mage::app()->getRequest()->getParam('field');
    
    0 讨论(0)
提交回复
热议问题