SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a cgi script that accepts data from a form. I would like to be able to submit data to it from loop, but the cgi is looking for variables from an form post action. Is it possible to write a php loop that will submit this data to that cgi on form at a time untill it processes all the data automatically. I know - This is clear as mud.

    Thanks for your help.
    Marty H.

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry but I don't think you can do that, if I'm understanding your question correctly.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, you can. I found this buried in the php manual.


    For those interested, this is how I've used the post method. As far as I know, post is used for sending data to cgi scripts. For example, say you want to call a cgi-script that will add an entry to a guestbook:
    // Data to pass to the cgi script
    $name = 'John Doe';
    $email = 'johndoe@domain.com';
    $msg = 'Nice site, I love your animated gif collection!';

    // Build the request string
    $request = 'name=' . urlencode($name);
    $request .= '&email=' . urlencode($email);
    $request .= '&msg=' . urlencode($msg);

    // Build the header
    $header = "POST /guestbook/add.php3 HTTP/1.0\r\n";
    $header .= "Content-type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-length: " . strlen($request) . "\r\n\r\n";

    // Open the connection
    $fp = fsockopen('www.domain.com', 80, &$err_num, &$err_msg, 30);
    if ($fp)
    {
    // Send everything
    fputs($fp, $header . $request);
    // Get the response
    while (!feof($fp))
    $response .= fgets($fp, 128);
    }


    This is what I need, I just haven't gotten it to work properly yet. I am working on it though. This doesn't have the loop, but that wil be modified when I can get it to work once.
    Marty H.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •