大家好 StackOverflow,
我正在尝试更多地了解 cURL 并提出以下表格:
<?php
//controleer of het formulier gesubmit is. Als dat zo is stuur de data door naar de link
if(isSet($_POST['submit']))
{
$ch = curl_init("http://jecom.nl/jecom/curl/receive.php");
//definieer de link
curl_setopt($ch, CURLOPT_POST, true);
//zet het type op post
curl_setopt($ch, CURLOPT_POSTFIELDS, "sender=" .$sender."&receiver=".$receiver."");
//stuur de gegevens uit het formulier door naar de link
curl_exec($ch);
//Zet de output op het scherm
if (curl_errno($ch))
{
print curl_error($ch);
//Als er een fout is geef deze dan
}
else
{
curl_close($ch);
//Sluit de link met de website
}
}
else
{
?>
<form method="POST" action="<? echo $_SERVER['PHP_SELF']; ?>" name="login">
<table width="100%">
<tr align="center">
<td width="50%" align="right"><font color="navy">Sender</font></td>
<td width="50%" align="left"><input type="text" name="sender" size="50"></td>
</tr>
<tr align="center">
<td width="50%" align="right" width="100"><font color="navy">Receiver</font></td>
<td width="50%" align="left"><input type="text" size="50" name="receiver"></td>
</tr>
<tr align="center">
<td width="50%" align="right" width="100"><font color="navy">Amount</font></td>
<td width="50%" align="left"><input type="text" size="50" name="amount"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr align="center">
<td colspan="2" align="center"><input name="submit" type="submit" value="Inloggen"></td>
</tr>
</table>
</form>
<? } ?>
这是我的接收端脚本:
<?php
// recipient.php
$sender = ($_POST["sender"]);
$receiver = ($_POST["receiver"]);
$amount = ($_POST["amount"]);
print "Greetings, visitor from {$_SERVER['REMOTE_ADDR']}";
echo ($_POST['sender']);
?>
它没有显示我的回声。即使我认为在两台服务器上都启用了 cURL。