0

现在我想将 POST 数据横向输入a.com/a.phpb.com/b.php.supposea.php有一个表单。

<form method="post" action="">
name: <input type="text" name="name" /><br />
email: <input type="text" name="email" />
</form>

以下是我的代码 php 代码部分a.php。如何接收横向数据b.com/b.php

    $url = 'http://www.b.com/b.php';
    $fields = array(
    'username' => addslashes($_POST['name']),
    'email' => addslashes($_POST['email']),
     'ip' => $_SERVER['REMOTE_ADDR']
);

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
 curl_close($ch);

如何编写表单动作部分?我的代码有问题吗?谢谢你。

4

1 回答 1

0

在 curl_close($ch) 之前,

url_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
于 2012-09-13T01:14:37.883 回答