标题可能有点误导,但我不确定如何以其他方式表达它。
我使用以下脚本发送变量跨服务器:
<?php
if($_POST) {
$ch = curl_init("http://jecom.nl/bank/mods/jecom/jecom.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,
array('description' => $_POST['description'], 'amount' => $_POST['amount'], 'receiver'=> $_POST['receiver']));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
// set to false if you want to see what redirect header was sent
// snippet 1
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
}
?>
这样可行,我将变量传递给另一台服务器上的jecom.php
。
这是接收页面:
<?php
require_once 'jecom_req.php'; //Basic requirements file
$receiver = ($_POST["receiver"]);
$amount = ($_POST["amount"]);
$description = ($_POST["description"]);
$sender = $_SESSION['username']; //their username.
$balance = get_funds($sender, $server);
?>
<h1>Confirm payment</h1>
<p>Please be carefull to confirm your payment to the other party. All transactions are logged to prevent fraud.</p>
<form name="confirmation" method="post" action="jecom_send.php">
<table width="200" border="1">
<tr>
<td>Your account name:</td>
<td><?php echo $sender; ?></td>
</tr>
<tr>
<td>Current Balance:</td>
<td><?php echo $balance; ?></td>
</tr>
</table>
<hr>
<table width="200" border="1">
<tr>
<td>Receiving party:</td>
<td><?php echo $receiver; ?></td>
</tr>
<tr>
<td>Description:</td>
<td><?php echo $description; ?></td>
</tr>
<tr>
<td>Amount:</td>
<td><?php echo $amount; ?></td>
</tr>
</table>
<hr>
<table width="500" border="1">
<tr>
<td align="center">I hereby confirm this information is correct and want to transfer the money.</td>
</tr>
<tr>
<td align="center"><input name="Submit" type="submit" value="Submit"></td>
</tr>
</table>
<input name="receiver" type="hidden" value="<?php echo $receiver; ?>" />
<input name="description" type="hidden" value="<?php echo $description; ?>" />
<input name="amount" type="hidden" value="<?php echo $amount; ?>" />
<input name="confirmation" type="hidden" value="http://jecom.nl/bank/mods/jecom/confirmation.php" />
</form>
我从表单中获取值(正如预期的那样)但不是$sender
和$balance
,当我按下提交时它也不会将它们发送到正确的页面但是希望找到{表单服务器上的{1}}。现在这并不让我感到惊讶,我想到了跟随位置,但目前这不起作用(jecom_find.php
和openbase_dir
仍然是一个)。是否有可能绕过这个?
答案 0 :(得分:0)
如果是跨服务器,则不会在第二台服务器上设置$ _SESSION变量。所以它总是为空,所以,你永远不会得到你的调用
$balance = get_funds( NULL , $server);