As I mentioned already you would be best not using Javascript and
performing the submission via PHP. I wrote the following snippet in the
past to do something similar to what you are asking. Study it and see if
you can adapt it to your own needs. You should be able to loop on the
form submission but you may want to disable script time limit if you
expect that this will take a while.

    function submitForm( $host, $path, $data )
    {
        $headerString =
            'POST '.$path.' HTTP/1.0'                           ."\r\n"
           .'User-Agent: Lynx ;)'                               ."\r\n"
           .'Host: '.$host                                      ."\r\n"
           .'Accept: */*'                                       ."\r\n"
           .'Content-type: application/x-www-form-urlencoded'   ."\r\n"
           .'Content-length: ';

        $postData = '';
        foreach( $data as $key => $value )
        {
            $postData .= urlencode( $key ).'='.urlencode( $value ).'&';
        }

        $postData = ereg_replace( '.$', '', $postData );

        $headerString .= ''.strlen( $postData )."\r\n\r\n";
        $headerString .= $postData."\r\n";

        $content = sendRequest( $host, $headerString );
        $content = implode( "\n", $content );

        echo 'CONTENT'."\n\n".$content."\n\n";
    }

    function sendRequest( $host, $header )
    {
        $fp = fsockopen
        (
            $host,
            80,
            $errno,
            $errstr,
            30
        );

        $data = '';

        if( !$fp )
        {
            echo "Error: $errstr ($errno)\n";
        }
        else
        {   
            fputs( $fp, $header );

            while( !feof( $fp ) )
            {
                $data .= fgets( $fp, 128 );
            }

            fclose( $fp );
        }

        return explode( "\n", $data );
    }

Cheers,
Rob.


On Tue, 2003-08-12 at 20:45, Kris Reid wrote:
> 
> ----- Original Message -----
> From: "Robert Cummings" <[EMAIL PROTECTED]>
> 
> > If I understand your question correctly it sounds like you want to
> > populate a database on Server A with data residing in a database on
> > server B via a form hosted on server A *grin*. Obviously this is
> > tedious, and if there are a lot of entries then I would suggest writing
> > a script to populate and submit the form automatically. If you are lucky
> > everything will be done via HTML GET method (URL parameters); however,
> > it is more likely that it uses the POST method. You can do some reading
> > into posting data via HTML request headers, or you can look and see if
> > there is a class that does what you want in PEAR or PHP Classes.
> >
> > HTH,
> > Rob.
> >
> 
> Robert
> 
> Thanks for explaining my situation better. That's spot on.
> I have php grabbing data from my database and filling the form. Then
> JavaScript automatically submits the form.
> However once the form is submitted. Server A forwards the browser else
> where. So I have to type in my URL again.
> 
> Is there some way I can more or less dump my database into theirs via the
> form. There are a #$%^ load of records.
> 
> Thanks
> 
> Kris
> 

-- 
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org   |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the  |
| stuff of nightmares grasp for your soul.    |
`---------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to