1

we updated our shop from 1.7.x to 1.9.2.2 and face a curios problem: On most of the devices the login form and registration form is working but not on all devices (Exactly, it works on all our devices, but some customers have this problem). After sending the forms the page is reloaded without error message and the action was not successful.

We inserted the hidden field "formkey" but are still having this problem. Any ideas where we can look at?

Our shop is www.begeisternderwahlkampf.de

1
  • I've said many times "it's not the form key" only to find out I put it in the wrong theme. Are you 100% sure that it's in the correct theme? Try switching to rwd/default and see if it works there first before debugging further.
    – philwinkle
    Jun 3, 2016 at 23:51

3 Answers 3

1

I know that you already inserted the formkey, but I had the same problem and I discovered that I was using the formkey in the wrong way.

1 - Make sure that you use this code to insert the formkey:

<?php echo $this->getBlockHtml('formkey'); ?>

2 - The code should be right after the line:

<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="login-form">

3 - Make the change in the right files:

app/design/frontend/base/default/template/customer/form/login.phtml
app/design/frontend/base/default/template/customer/form/register.phtml

or, if you are using a custom theme:

app/design/frontend/COMPANY/THEME/template/customer/form/login.phtml
app/design/frontend/COMPANY/THEME/template/customer/form/register.phtml

Good luck :)

0

Thank you guys for your help.

We used the correct theme, checked this in the HTML source code on the site.

But the form key was programmed like this:

<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />

I replaced it with

<?php echo $this->getBlockHtml('formkey'); ?>

We will see, if this solves the problem for the last 10% of our visitors. My browser gets the same source code than before but maybe it makes the difference on the machines where it failed before. I will let you know.

0

This is issue of Magento function ->getParam()

The value of form_key is null at form_key processing time, it gives -1 value

You need to override controller action

Mage_Core_Controller_Varien_Action

from

protected function _validateFormKey()
{
    if (!($formKey = $this->getRequest()->getParam('form_key', null)) || $formKey != Mage::getSingleton('core/session')->getFormKey()) {
        return false;
    }
    return true;
}

To

protected function _validateFormKey()
{
     if (!($formKey = $this->getRequest()->getPost('form_key', null))
        || $formKey != Mage::getSingleton('core/session')->getFormKey()) {
        return false;
    }
    return true;
}

Now customer created successfully!

Your Answer

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

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