3

I tried every possible thing get when I using the get method it works fine but post does not send any value. using this in my controller.

$post = $this->getRequest()->getPostValue();

but got a empty array. form content

$controller_path = $block->getUrl('module name/activate');
           <form method="post" id="form1" name="form1"  action="<?php echo $controller_path;?>" >
                <p><b><span style ="color:#14497f";>Please confirm your email address:</span></b>
                <input type="email" placeholder="Admin email address" style =" margin-left:5px;" size="30"  name="email" /><b>
                <input type="submit" name="submit" class="button" style ="margin-left:2px;background: #14497f none repeat scroll 0% 0%;border-color: #14497f;color: #FFF;" value="Proceed to the final step">
6
  • 1
    kindly add your your form code? Commented Jul 18, 2016 at 6:18
  • 1
    try this $this->getRequest()->getPost() or direct $this->getRequest()->getPost('email') Commented Jul 18, 2016 at 6:33
  • @Qaisar Satti i tried this also. Commented Jul 18, 2016 at 6:35
  • did you get values in $_POST[]? Commented Jul 18, 2016 at 6:36
  • @Qaisar Satti empty Commented Jul 18, 2016 at 6:39

2 Answers 2

6

You can try

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

You can access specific parameter by

$this->getRequest()->getParam('something');

Post form action

<form id="yotpo-form" action="<?php echo $block->getFormActionUrl() ?>" method="post">
    <?php echo $block->getBlockHtml('formkey')?>
    <input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
    <input id="app_key" type="text" value="<?php echo $block->_config->getAppKey();?>" class="
</form>

Inside your Block

public function getFormActionUrl()
{
    return $this->getUrl('feedback/index/post', ['_secure' => true]);
}

Make sure your Back end controller extend Magento\Backend\App\Action I tested in my controller, those are working fine. if not working there is something went wrong in posting.

Fell free to share your code if not working, hope this helps.

5
  • i tried this but got nothing .. and i am working in backend so extends Magento\Backend\App\Action; this Commented Jul 18, 2016 at 6:33
  • i check this also it work good Commented Jul 18, 2016 at 6:39
  • okay i can try this one Commented Jul 18, 2016 at 6:56
  • 1
    I think you missed Form key, Please try to go with my updated answer. and check this reference link magento.stackexchange.com/questions/90382/… Commented Jul 18, 2016 at 7:11
  • thanks it works you are right form-key is missing i add the form key then it works :) Commented Jul 18, 2016 at 9:08
1

I have faced same problem ago

I got blank array in post due to some misconfiguration of .htaccess rule

I will suggest you changed your .htaccess with fresh one

may be it helpful to you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.