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
  • 37,721
  • 29
  • 123
  • 200
Simon
  • 5,016
  • 7
  • 41
  • 64

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
  • 103,526
  • 30
  • 178
  • 200
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
  • 37,721
  • 29
  • 123
  • 200