CMS页面上的Magento客户登录表单无效

时间:2017-09-21 13:03:46

标签: php forms magento magento-1.9

我试图获取已被CMS页面调用的登录表单,但在测试时,它会重定向回页面并且不会将用户登录。

我想这与没有正确的表单密钥有关,因为我注意到默认登录页面具有URL格式,

  

www.mydomain.com/customer/account/login/referer/blahblahblah /

并且表单调用函数getPostActionUrl(),该函数为表单操作生成此URL,

  

www.mydomain.com/customer/account/loginPost/referer/blahblahblah /

那么如何让我的表格使用那个blahblahblah键?

表单会生成一个名为form_key的隐藏输入。但这与blahblahblah并不相同。

以下是表单的代码。任何人都可以建议如何获得blahblahblah密钥以及在表单代码中放置它的位置?

<div class="block block-login">
<div class="block-title">
    <strong><span><?php echo $this->__('Login') ?></span></strong>
</div>
<?php echo $this->getChildHtml('customer.form.login.extra')?>
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="login-form">
    <?php echo $this->getBlockHtml('formkey'); ?>
    <div class="block-content">
        <label for="mini-login"><?php echo $this->__('Email:') ?></label>
        <input type="text" name="login[username]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Email Address')) ?>" />
        <label for="mini-password"><?php echo $this->__('Password:') ?></label>
        <input type="password" name="login[password]" class="input-text required-entry validate-password" id="pass" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Password')) ?>" />
        <div class="actions">
            <button type="submit" class="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Login')) ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
        </div>
    </div>
</form>
<script type="text/javascript">
//<![CDATA[
var dataForm = new VarienForm('login-form', true);
//]]>

1 个答案:

答案 0 :(得分:0)

通过一些研究来实现这一目标。

首先,我找到了这个帖子:Magento adding referer param to getLoginPostUrl()

这为我提供了部分成功解决方案的基础。

首先,在

  

应用程序/设计/前端/碱/默认/模板/ CMS / cmslogin.phtml

(我为此登录表单创建的自定义文件)

我换了,

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

用,

<?php $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME); 
echo Mage::helper('core')->urlDecode($referer);
?>
<form action="<?php echo Mage::getUrl('customer/account/loginPost', array('referer' => $referer)); ?>" method="post" id="login-form">

似乎只需要登录表单就可以了。

我现在遇到的问题是,尽管“配置&gt;客户&gt;客户配置&gt;登录选项&gt;登录后重定向客户到帐户信息显示板”设置为否,表单将重定向到信息中心 - 我希望它重定向回CMS页面(当用户登录并且特定客户组的成员显示不同的内容时)。会另外问这个。