Forms: Submit to two at once?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alix
Forum Commoner
Posts: 42
Joined: Thu Nov 18, 2004 8:41 am

Forms: Submit to two at once?

Post 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?
User avatar
emperor
Forum Newbie
Posts: 16
Joined: Tue Mar 02, 2004 11:20 am
Location: UK

Post 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);
?>
alix
Forum Commoner
Posts: 42
Joined: Thu Nov 18, 2004 8:41 am

Post by alix »

Awesome, im gonna give this a shot.. will let you know on results. Thanks alot. 8)
Post Reply