Page 1 of 1

Forms: Submit to two at once?

Posted: Thu Nov 18, 2004 8:45 am
by alix
Hi all, im having a small problem. I have a form that the information needs to be sent to two differant places. Once it is sent to one place i dont have control of where it goes from there (ie. its not my site). Is there a way with PHP that i can submit to both places at the same time?

Posted: Thu Nov 18, 2004 9:00 am
by emperor
You can post info to external sites manually with PHP using [php_man]fsockopen[/php_man]. There may be an easier way but this is how I do it:

Code: Select all

<?php
    $url = fsockopen ('http://www.blah.com', 80);

    $data = 'variable=value&variable2=something';
    $length = strlen ($data);

    $post = "POST /path/to/script HTTP /1.0\n";
    $post .= "Content-Length: $length\n";
    $post .= "Content-Type: application/x-www-form-urlencoded\n";
    $post .= "Connection: Close\n\n";
    $post .= "$data\n\n";

    fputs ($url, $post);
    fclose ($url);
?>

Posted: Thu Nov 18, 2004 9:23 am
by alix
Awesome, im gonna give this a shot.. will let you know on results. Thanks alot. 8)