CURLOPT_POST question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmilane
    New Member
    • Sep 2006
    • 1

    CURLOPT_POST question

    Hi,

    I am trying to use curlop_post to post $_POST to another server that does not have a public IP. I have the form pass all its data to an intermediary file that contains this code:

    Code:
    $ch = curl_init("http://oldserver.mycompany.com/somepage.php");
    curl_setopt($ch, CURLOPT_POST); //use the POST method
    curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); //take the $_POST array
    and use those as the POST parameters for the curl request
    curl_exec($ch); //execute the request
    but it does not work, because i guess CURLOPT_POSTFIE LDS expects a string.

    im stuck.

    help, if you can?

    I am new to PHP, in over my head!! :P

    Thanks a LOT.

    J
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Try this one
    [php]
    <?php
    // create a new curl resource
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch , CURLOPT_URL, "http://my.site.com/form.php");

    // Do a POST
    curl_setopt($ch , CURLOPT_POST, true);
    curl_setopt($ch , CURLOPT_POSTFIE LDS, $_POST);

    // grab URL, and print
    curl_exec($ch);
    ?>
    [/php]

    Ronald :cool:

    Comment

    Working...