从 php Zend-Framework 站点发送 POST [英] Send POST from php Zend-Framework site

查看:31
本文介绍了从 php Zend-Framework 站点发送 POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 ACL 开发一个 zend 框架站点.

I am currently working on a zend framework site using an ACL.

ACL 工作并使用 DB 来存储特权.到目前为止,我所做的是,在 preDispatch 中,我捕获了用户想去的地方,如果他们需要登录才能到达那里,页面会显示登录表单.我还捕获了用户是否提交了表单并存储了数据(位置和表单数据).目前没有问题.

The ACL works and uses a DB for storing privaliges. What I have done so far is, on in a preDispatch I capture where the user wanted to go to, and if they need to login to get there the page displays the login form. I have also captured if a user has submitted a form and stored the data (location and form data). No problems so far.

用户提交登录表单,然后我检查我是否有可以将它们发送到的位置,这里再次没有问题,这是有效的.

The user submits the login form, and I then check if I have a location to send them onto, again no problems here, this works.

但是,我希望现在能够提交原始表单数据,它们已经过身份验证 - 唯一的问题是,如果我将它们重定向到页面,调用:

However I want to be able to submit the original form data now they are autherised - the only problem is, if I redirect them to the page, the call to:

$this->getRequest()->isPost()

失败,因为它不是发布请求.

fails as it isn't a post request.

我可以在成功登录时将用户转发到页面,并且在 preDispatch 中将 $_POST 设置为最初捕获的数据,这在原始 POST 仍然有效的情况下有效,但我认为这不是正确的方法这 - 特别是 URL - 显然显示的页面是正确的,表单已正确提交,但 URL 是登录过程的.

I can forward the user to the page on sucessful login, and in the preDispatch set $_POST to the data originally captured, this works as the original POST still stands, this works but I do not think is the correct way to do this - specially the URL - obviously the page displayed is correct, the form has been submitted correctly, but the URL is of the login process.

显然我可以改变使用 $this->getRequest()->isPost() 但由于有大量需要更改,我希望不必这样做.

Obviously I could change from using $this->getRequest()->isPost() but as there are large amounts which would need changing I was hoping not to have to do this.

推荐答案

通常的做法(在许多网站上都看到过),将在会话中存储表单数据和请求的操作,然后将用户重定向到登录页.当登录被授权时,您读取任何挂起操作的会话,重新加载表单并用会话中的数据填充它(之后正确清除会话中的任何挂起操作).用户只需再次点击提交即可.

The way it's done usually (seen this on many sites), would be to store the form data and requested action in session, then redirect the user to a login page. When login is authorized, you read the session for any pending action, reload the form and populate it with data from session (properly clearing any pending action from session afterwards). The user would just have to click Submit again.

另一种方法是使用 HttpClient 并将数据作为 POST 提交.

The other way to do this would be to use HttpClient and submit the data as POST with it.

这篇关于从 php Zend-Framework 站点发送 POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆