Post and Redirect
am 26.02.2010 20:26:26 von Shawn McKenzie
I remembered seeing this question on the list several times in the past,
so I thought I would post something I just hacked up for someone.
As we know, we can user header() to redirect the browser, but of course
we can't redirect the browser and have it post data to the new page. If
you need to do this it will require javascript. Here's a quick and
dirty function:
function http_post_redirect($url='', $data=array(), $doc=false) {
$data = json_encode($data);
if($doc) {
echo "
";
}
echo "
";
if($doc) {
echo "";
}
exit;
}
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Post and Redirect
am 26.02.2010 21:20:23 von Ashley Sheridan
--=-7j7elf/ATR6qGUPLvFtW
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Fri, 2010-02-26 at 13:26 -0600, Shawn McKenzie wrote:
> I remembered seeing this question on the list several times in the past,
> so I thought I would post something I just hacked up for someone.
>
> As we know, we can user header() to redirect the browser, but of course
> we can't redirect the browser and have it post data to the new page. If
> you need to do this it will require javascript. Here's a quick and
> dirty function:
>
> function http_post_redirect($url='', $data=array(), $doc=false) {
>
> $data = json_encode($data);
>
> if($doc) {
> echo "
";
> }
> echo "
> ";
>
> if($doc) {
> echo "";
> }
> exit;
> }
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
Someone mentioned on the whatwg mailing list that most browsers are
capable of understanding multipart content, so that you could send down
two types of content a bit like you'd send a multipart email.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-7j7elf/ATR6qGUPLvFtW--