0

I have a form that users post to but now this form is going to handled on an external website to my application.

I have tried using Location and curl and can not manage to get any of these to function correctly. My goal is to take the $_POST from my form and redirect the user to the external website posting the values.

Is this possible without using an html form and javascript to submit it?

Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
  • 1
    Possible duplicate of [PHP Redirection with Post Parameters](http://stackoverflow.com/questions/2865289/php-redirection-with-post-parameters) – wogsland Jun 02 '16 at 21:11

1 Answers1

0

Sending the Location header like that will generate a HTTP 302 response to tell the browser to go elsewhere, however, this will cause the browser to retry with a GET request.

If you want to redirect with the original method and parameters, you need to send code 307 or 308, depending on whether the redirect should be considered temporary or permanent. You can do this in PHP using http_response_code, e.g.

http_response_code(308);
header("Location: www.google.com");
slugonamission
  • 9,562
  • 1
  • 34
  • 41