i'm new to magento. I trying to make a form to add some user to my database (not with form from magento, i need to check if the user exists in my xml file...). When I submit my form, I need to check if the user exists (it's done and working). If the user doesn't exists, I need to redirect. If it exists, i need go redirect to another form page, so that the user can sign in by adding email and password. Or (1) I have no idea how to get parameters from the first form and my redirect is not working. I have this for my first redirect (if it doesn't exists) :


And this if the user exists in my xml :

$this->_redirect('connexion/connexion/Form', array('name' => $name, 'code'=>$code));

I have two views, one for the first form and the other's got only some text to see if i'm on the right page, but nothing appear on this page (no content, only footer and header).

Please i need your help PS : i'm used to Symfony but Magento seems to be pretty different :/ PS 2 : i'm using 2.2.4 version

EDIT : now my page display some content, i'm looking for how to get parameters from the previous form and redirects still not working

2 Answers 2


if you are trying to receive your parameters in your php file you should use the line

$variableName = $_POST['name of form input field'] ?? '';
$variableName2 = $_POST['name of form input field'] ?? '';
$variableName3 = $_POST['name of form input field'] ?? '';

do this for each of the inputs in the form.

you can then display them on the page using

echo "<p>" . $variableName . "</p>"

I hope this helps


In Controller File, Code would be like this.....

protected $_customerInterface;

public function __construct(\Magento\Customer\Model\Data\customer
$customerInterface,\Magento\Framework\App\Action\Context $context)

  $this->_customerInterface = $customerInterface;


 public function execute()
$postvalues  = $this->getRequest()->getPost();

$postvalues['email']  /* This is Mail address of customer.*/

$mailAddress = $this->_customerInterface->getEmail();/* get Result If Customer Session exist*/

if($mailAddress == $postvalues['email'])
        $resultRedirect = $this->resultRedirectFactory->create();
        $resultRedirect->setPath('*/*/');// your path
        return $resultRedirect;
        $resultRedirect = $this->resultRedirectFactory->create();
        $resultRedirect->setPath('*/*/');your path
        return $resultRedirect;
  • Can you please give more details ? Is that in the execute method ? Btw, when i try to use Mage, PHPStorm is saying that Mage doesn't exists May 23, 2018 at 15:48
  • are you working on m1 or m2?
    – MR.R DNATH
    May 23, 2018 at 15:55
  • I'm working with magento 2.2.4 May 23, 2018 at 16:00
  • Hi, I will explain again, i think we don't understand each other ^^. I have my first form (with two fields, name and code). If the code exists, I want to redirect to another page with the second part of the form (with mail, password and the two values previously declared). So here i'm a bit confused, where am i suppose to use your code ? May 24, 2018 at 7:45

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.