Send POST from php Zend-Framework site

 ̄綄美尐妖づ 提交于 2019-12-24 08:59:23

问题


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

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.

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.

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.


回答1:


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.

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



来源:https://stackoverflow.com/questions/4069302/send-post-from-php-zend-framework-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!