How to receieve the value from php curl transverse data?

0 down vote favorite

Now i want to transverse POST data in a.com/a.php to b.com/b.php.suppose a.php has a form.

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

the following is my code php code part in a.php. how to receieve the transversed data in 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);
$result = curl_exec($ch);
 curl_close($ch);

how to write the form action part? is there something wrong with my code? thank you.

a.php’s form indicates that it will be sending the data to a.php, not b.php.

Action=“” is translated by browsers as “Send this to myself.”

If you’re using a.php to curl the postvalues to b.php, then b.php should be constructed as if it were the normal receiver (get fields out of $_POST, etc).

Are a.com and b.com on the same machine?

serialize your $fields array.