Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirect to new page w/ POST data (PHP/Zend)
    text
    copied!<p>I'm trying to figure out how to redirect to a new page (different application, controller, action) and maintain the current POST data.</p> <p>My app is validating the POST data and if a certain criteria is met, I want to redirect to a different location, but make sure the POST data is passed as POST data to that new page. Here's a rough example:</p> <pre><code>POST /app1/example HTTP/1.1 Host: example.com Content-Type: application/x-www-form-urlencoded Content-Length: 17 var1=foo&amp;var2=bar </code></pre> <p>In my <code>exampleAction</code> (Zend_Controller_Action), I check to see if <code>var1 == foo</code>, and if it does I want to redirect (302) to /app2/example with that same POST data. Something maybe like this?</p> <pre><code>HTTP/1.x 302 Found Location: /app2/example Content-Type: application/x-www-form-urlencoded Content-Length: 17 var1=foo&amp;var2=bar </code></pre> <p>I can see how to create a new HTTP request using Zend_Http_Client, but I'm not looking to simply request the page and display the content. Should I still be looking to use Zend_Http_Client anyway? At the moment I'm playing with stuff like this:</p> <pre><code>$this-&gt;getResponse()-&gt;setRedirect('/app2/example/', 302); $this-&gt;getResponse()-&gt;setBody(http_build_query($this-&gt;_request-&gt;getPost())); </code></pre> <p>I'm sure what I want to do is possible through some means of trickery and demon-cavorting, but it's definitely alluding me. Any help is appreciated.</p> <p>- rk</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload