0
votes

Is there a way to prepare form data in php on one server, and then open and fill that data in form that lies on another server?

So, I have mypreparation.php on SERVER/DOMAIN1, where I prepare data. On SERVER/DOMAIN2 is form.php that can read POST variables and prefill them in input and textarea tags, if POST vars are set.

How can I prepare and send POST data from mypreparation.php (SERVER1), and get page form.php (SERVER2) opened in my browser, with filled data from mypreparation.php?

From user perspective, flow looks like this. User is on DOMAIN1, where she has a link. When she clicks the link, php prepares data and opens form on DOMAIN2 with filled data, waiting for user to click Send. Data can't be sent with GET because it's larger.

This is to be done without javascript, just php1 to php2 which creates html. I control both mypreparation.php and form.php. Any ideas? Thank you.

2
I'm not sure I understand the flow, does the user ever enter DOMAIN1 or does the user only interact with DOMAIN2? - jeroen
User is on DOMAIN1, and on DOMAIN1 she has a link. When she clicks the link, php prepares data and opens form on DOMAIN2, with filled data. - Marko
Anybody? Php1 from DOMAIN1 sends post data to php2 on DOMAIN2 and php2 opens in user browser with prefilled data. Is it possible? - Marko
I will update my answer. - Digital Chris
@Digital Chris: Ok, as I researched in the meantime I saw that your final solution is right solution. But, it's not as straight forward as I wanted. So I'll do it with ajax invisible form, as originaly planned. Thank you anyway for your time and answer. - Marko

2 Answers

0
votes

After discussion, it seems you want to use server-to-server communication. This can be accomplished with cURL. PHP in Server1 will serve a page to the user with a link in the format:

https://www.server2.com/someurl.php?secretkey=12341234

At the same time, server1 will submit a cURL post to server2 with data:

secretkey=12341234
otherdata=something
moredata=somethingelse

Server2 will save the form data and a request to its someurl.php will use the secretkey to load the data and build a form for the user.

0
votes

Like this ?

The link: http://www.whatever.com?var1=123&var2=456&....

In Domain 2 you can extract this data with GET['var1'], GET['var2'], ... And echo it in the form fields.

Example

<form>
  <input type = "text" value = "<?php echo GET['var1']; ?>">
</form>

Cheers