Update: This is NOT a duplicate of How do I send a POST request with PHP?. The solutions there don\'t work for me, they just output the result of the request, I don\'t w
AJAX could be use in this case.
The form on mysite.com/pay points to gatewaysite. On submit you run a function which will call script.php. Only if script.php confirms that the data is correct, the form will be submitted.
Its not possible,beacuase the page loaded entirely,there is a chance with empty data with POST request,instead of using this create Sessions when ever required,and after usage of that session just destroy the session. And the second one is usage of CURL .
If you are the owner of both websites, then you can just include the sites in each .htacess file, that will remain encypted.
The qualifications for this is SSL CA on both sites.
in your .htaccess, you do this by: this added in site#1's htaccess:
RewriteCond %{HTTP_REFERER} !^https://www.site2.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site2.com$ [NC]
this added in site#2's htaccess:
RewriteCond %{HTTP_REFERER} !^https://www.site1.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://www.site1.com$ [NC]
Then you can use a standard html form on site#1 like:
<form action="https://wwww.site2.com" method="POST">
Long story short: no, it's not possibile using PHP.
One way I can think of doing this is to output the new form output as hidden fields along with javascript to auto-submit the form ...
It's the only way to do it.
The question is a possible duplicate of PHP Redirect with POST data.
As a suicide solution, you may consider to use HTTP 307 - Temporary Redirect.
From the HTTP/1.1 documentation linked above:
If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
My bold simply emphasizes that the redirect without the user confirmation actually depends on the browser's implementation of the protocol.
The redirect can be implemented in the PHP script which receives the POST request as follows*:
header('HTTP/1.1 307 Temporary Redirect');
header('Location: <your page in an external site>');
Basic usage Example:
page1.html - the page which contains the form
<html>
<body>
<form method="POST" action="page2.php">
<input name="variable1" />
<input name="variable2" />
<input type="submit" />
</form>
</body>
</html>
page2.php - the page which processes your POST data before redirect
<?php
if (isset($_POST['variable1']) && isset($_POST['variable2'])) {
//do your processing stuff
header('HTTP/1.1 307 Temporary Redirect');
header('Location: page3.php');
exit;
} else
echo 'variable1 and variable2 are not set';
page3.php the page to which the POST data has to be redirected (i.e. the external site)
<?php
if (isset($_POST['variable1']) && isset($_POST['variable2'])) {
foreach ($_POST as $key=>$val)
echo $key . ' = ' . $val . '<br>';
} else
echo 'variable1 and variable2 are not set';
* don't try this at home!