Using PHP, is it possible to send post data to another domain without using a form?
header('location:https://domain.com/webservice/?data=My Data');
We can't use the solution above because the GET data is stored in the persons browser history and in some of our server logs (not ideal).
curl_init();
We can't use this solution because the /webservice/
uses a header('location:')
to redirect the user to a final landing page and curl_init()
captures the data instead of responding to it -- our goal is to have the user change domains along with the post data. The /webservice/
also creates a new session with the user which is why they need to be at that physical location with the post data.
Anyone have an outside-the-box idea?
You can make a POST request from your PHP program (see the cURL library) but you can't redirect the browser in such a way that it will make a POST request.
The only way to do that is to generate an HTML document with a form and POST that (which can be done using JS).
Here's my solution, provided both domains can share the same database.
Steps:
Additionally you can have a status field to time-out the data and delete the record if it's not read within a certain time period.
Well, this is only an idea but I think it's a workable one that hides your data to some extent compared to sending it all in the query string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.