3

I need to cause a user's browser to post data using PHP to another site.

Example: You go to start.com/auto-login-hack (via GET)... then PHP sets the right headers etc. and causes the browser to, via POST, go to 3rdparty.com/login.php with login credentials.

I have done this is the past by having an HTML form and an onload script that submits the form to the destination.

I don't know enough about headers and etc. Is this possible? Can anyone link an example? My search skills just turned up how to use $_POST.

Thanks.

David Pfeffer
  • 38,869
  • 30
  • 127
  • 202
Simon
  • 5,158
  • 8
  • 43
  • 65

2 Answers2

7

Yes, you can submit POST requests from PHP.

One of your choices is to use curl as shown in this SO question.

However, you cannot do redirects.

Community
  • 1
  • 1
Peter Bailey
  • 105,256
  • 31
  • 182
  • 206
4

You cannot redirect to a POST; this is a limitation of HTTP. You'd have to use JavaScript to cause the browser to post a form.

David Pfeffer
  • 38,869
  • 30
  • 127
  • 202