0

Possible Duplicate:
Response.Redirect with POST instead of Get?

I need to redirect a user from one page to another, that's easy, but that second page is actually a page that will take the POST variables and print the page. What I need is the function (if it exists) that will let me redirect the user and also send that data by POST to the page Im redirecting the user to.

Community
  • 1
  • 1
subharb
  • 3,374
  • 8
  • 41
  • 72
  • but that's on ASP, Im looking for the answer on PHP – subharb Oct 11 '12 at 13:11
  • The ASP.NET specific parts of that (which send the headers that the main answer notes are not supported properly by some popular browsers) are easily portable to PHP if you want to use them, despite that warning. – Quentin Oct 11 '12 at 14:08

3 Answers3

0

You can't send POST data in PHP when redirecting via header(). You could use CURL to send POST data to another script, but that wouldn't redirect the user.

Couldn't you just check the $_REQUEST array instead of $_POST in the taregeted script? This way it doesn't matter, whether the data comes via POST or GET.

feeela
  • 29,399
  • 7
  • 59
  • 71
0

Here is a link explaining about sending POST data without the curl

http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/

You can also use session global array if that works.

Abhishek Bhatia
  • 716
  • 9
  • 26
-2

How are you redirecting this user? And where do you want to pull the post data from?

If you are using a form, you can pass other POST variables with it using a hidden field. For example:

<form action="<URL>.php" method="POST">
<input type=”hidden” name=”Language” value=”Spanish”>

Full name: <input type="text" name="full_name" />

<input type="submit" value="Submit" />

</form>

In this instance, on the next page you could call $_POST["full_name"] and $_POST["Language"].

Josh J
  • 78
  • 1
  • 6
  • "How are you redirecting this user?" — Presumably with HTTP, that's how you do redirects on the WWW. "And where do you want to pull the post data from?" — The original request, that's where you get data from when doing redirects. – Quentin Oct 11 '12 at 08:42
  • 4
    Firstly there's no need for that kind of attitude. I feel like he could explain what he is trying to do better. I don't feel like my answer is particularly what he's looking for, but I posted it as he said "take the POST variables" which must have had to come from somewhere like a form. If he is meaning a link that takes previously POSTed data, then ignore this completely. Just trying to help. – Josh J Oct 11 '12 at 08:44