简体   繁体   English

在Zend Framework中提交后重定向到上一页

[英]Redirect to previous page after submit in Zend Framework

I know this has been answered somewhat but I can't seem to get it work for my specific config. 我知道这已经得到了一定的回答,但是我似乎无法使其针对我的特定配置起作用。 Apologies if this is deemed a duplicate. 抱歉,如果这被视为重复。

I have a cart built in Zend with a button that points to a login page via: 我有一个Zend内置的购物车,带有一个通过以下按钮指向登录页面的按钮:

if(!$session->id)
{
  header('Location:'.$fullurl.'login');
}

The button is inside a form by itself. 该按钮本身位于表单内部。 I've tried Arne's suggestion below with no dice. 我尝试了以下没有骰子的Arne的建议。 Form code: 表单代码:

<form name="" action="' . $fullurl . 'continue" method="post">
   <input type="submit" name="topay" value="CONTINUE SHOPPING" />
</form>';

How do I get and redirect to the last page visited rather than going to /login? 如何获取并重定向到上次访问的页面,而不是转到/ login?

I've tried doing the old HTTP_REFERER method but couldn't get it to work in Zend.. I understand there's a different method in Zend but can't get it to work from various answers here and here . 我已经尝试过使用旧的HTTP_REFERER方法,但无法在Zend中使用它。.我知道Zend中存在另一种方法,但无法从此处此处的各种答案中获得使用。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

I would use this: 我会用这个:

$url = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$session = new Zend_Session_Namespace('Namespace');
$session->redirect = $url;

// redirect
$this->_redirect($url, array('prependBase' => false));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM