PHP help needed. Any experts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 3Xguru
    Confirmed User
    • Sep 2001
    • 1281

    #1

    PHP help needed. Any experts?

    I'm working on a script that fills out forms automaticaly.
    The form url's are stored in a database, and I need to submit the variables to the forms using the post method.
    The problem is that I do not know how to automaticaly submit the forms in php(without pressing a button for each form)

    The code would look something like this:
    PHP Code:
    <?php
    
    for($i=1;$i<10;$i++){
    $url_form="http://www.anotherserver.com/form".$i.".php";
    $name="John";
    }
    ?>
    How do I submit the variable $name to all 10 external forms in the loop using the POST method?
    -=Free Webmaster Tools=-
  • Libertine
    sex dwarf
    • May 2002
    • 17860

    #2
    Open a socket connection, send the proper HTTP request, close the socket.
    /(bb|[^b]{2})/

    Comment

    • 3Xguru
      Confirmed User
      • Sep 2001
      • 1281

      #3
      How do I do it? With the socket...
      Can you post an simple example.
      I have been trying to find a solution on Google for hours and my head hurts
      Last edited by 3Xguru; 05-27-2003, 03:59 AM.
      -=Free Webmaster Tools=-

      Comment

      • Libertine
        sex dwarf
        • May 2002
        • 17860

        #4
        http://php.net/manual/nl/function.fsockopen.php
        Read this.
        /(bb|[^b]{2})/

        Comment

        • Libertine
          sex dwarf
          • May 2002
          • 17860

          #5
          And here's an example from that page which might be helpful (no, I am lazy today, so I won't write you some custom code):

          PHP Code:
          //create a string with all the posted data...
          
          foreach ($HTTP_POST_VARS as $key => $value) {
          $value = urlencode(stripslashes($value));
           $req .= "&$key=$value";
          }
          
          //create headers...
          
          $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
          $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
          $header .= 'Content-Length: ' . strlen($req) . "\r\n\r\n";
          $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
          
          if (!$fp) {
           // ERROR
           echo "$errstr ($errno)";
          } else {
          
          //put the data..
           fputs ($fp, $header . $req);
           while (!feof($fp)) {
          //read the data returned...
             $res = fgets ($fp, 1024);
          
          }
           fclose ($fp);
          } 
          
          /(bb|[^b]{2})/

          Comment

          • 3Xguru
            Confirmed User
            • Sep 2001
            • 1281

            #6
            Thanks punkworld

            You really helped me a lot!
            -=Free Webmaster Tools=-

            Comment

            Working...