Re-using POST data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RonS
    New Member
    • Sep 2006
    • 4

    #16
    Uhhh Thanks Ronald,

    But sending me to a 5 page, poorly written "tutorial" on curl that doesn't answer the question that I asked and showed an example using urlencode which I specifically said I didn't want to do doesn't quite satisfy my needs! lol :D

    I can RTFM too, I was hoping someone with experience could make my life a little easier today (or 2 days ago).

    Next time, please just say "I don't know" or nothing instead of sending me on a wild goose chase. I already have wild turkeys riunning around in my backyard, that's fowl enough for me. ;)

    Thanks.
    Ron.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #17
      Obviously, you have no intention of being shown the way to get to the solution of your problem. You also do not want to invest any time in acquiring new knowledge and learning anything new, such as CURL (which would actually help you achieve your goal).

      Nosir, not for you: you want the answer, you want it in code, and you want it now! And if you don't get exactly that, you blame others for your failure to comprehend.

      Ronald :cool:

      Comment

      • RonS
        New Member
        • Sep 2006
        • 4

        #18
        Hey dude,

        In my last job I was head of 3 departments, before that various shades of programming manager for years, a development dude for many years before that. I've probably hired, trained, managed and groomed more professional coders than you've known in your life, even though you claim 37 years of coding.

        I know how to read the manual, I even know the URL for php.net. Further, I went as far as to publish my own devised method for accomplishing the task and was clearly asking if there was a better way, not just a different and completely less elegant way. I stopped in, registered and asked for help because I was googling this problem and found this thread with a very similar situation. I was hoping the person giving advice was actually qualified.

        You sent me to a completely bull.... site with bad examples, no useful commentary, specifically didn't answer my question and did exactly what I stated I didn't want to do. Tell me, how were you helpful? ..and now you're offended because I called you on it?

        I can read the manuals, and I can assemble a series of php functions that will get the job done, but I'd to see some examples from others in how they would accomplish such a task, because over the years I've actually learned that I'm not always right.

        Not insignificantly , curl will almost certainly not be installed, compiled into php, or available to be used on all of my client's machines.

        Finally, If you just want to be an index for wikipedia, how about posting a link to something of quality like this?

        [php]//Here's a slightly modified version of sendtohost():

        /* sendToHost
        * ~~~~~~~~~~
        * Params:
        * $host - Just the hostname. No http:// or
        /path/to/file.html portions
        * $method - get or post, case-insensitive
        * $path - The /path/to/file.html part
        * $data - The query string, without initial question mark
        * $useragent - If true, 'MSIE' will be sent as
        the User-Agent (optional)
        *
        * Examples:
        * sendToHost('www .google.com','g et','/search','q=php_ imlib');
        * sendToHost('www .example.com',' post','/some_script.cgi ',
        * 'param=First+Pa ram&second=Seco nd+param');
        */

        function sendToHost($hos t,$method,$path ,$data,$userage nt=0)
        {
        // Supply a default method of GET if the one passed was empty
        if (empty($method) ) {
        $method = 'GET';
        }
        $method = strtoupper($met hod);
        $fp = fsockopen($host , 80);
        if ($method == 'GET') {
        $path .= '?' . $data;
        }
        fputs($fp, "$method $path HTTP/1.1\r\n");
        fputs($fp, "Host: $host\r\n");
        fputs($fp,"Cont ent-type: application/x-www-form- urlencoded\r\n" );
        fputs($fp, "Content-length: " . strlen($data) . "\r\n");
        if ($useragent) {
        fputs($fp, "User-Agent: MSIE\r\n");
        }
        fputs($fp, "Connection : close\r\n\r\n") ;
        if ($method == 'POST') {
        fputs($fp, $data);
        }

        while (!feof($fp)) {
        $buf .= fgets($fp,128);
        }
        fclose($fp);
        return $buf;
        }[/php]
        Source: http://www.faqts.com/knowledge_base/...id/12039/fid/5

        Or perhaps something like this:
        [php]
        <?php
        function post_it($datast ream, $url) {
        $url = preg_replace("@ ^http://@i", "", $url);
        $host = substr($url, 0, strpos($url, "/"));
        $uri = strstr($url, "/");
        $reqbody = "";
        foreach($datast ream as $key=>$val) {
        if (!is_empty($req body)) $reqbody.= "&";
        $reqbody.= $key."=".urlenc ode($val);
        }
        $contentlength = strlen($reqbody );
        $reqheader = "POST $uri HTTP/1.1\r\n".
        "Host: $host\n". "User-Agent: PostIt\r\n".
        "Content-Type: application/x-www-form-urlencoded\r\n" .
        "Content-Length: $contentlength\ r\n\r\n".
        "$reqbody\r \n";
        $socket = fsockopen($host , 80, $errno, $errstr);

        if (!$socket) {
        $result["errno"] = $errno;
        $result["errstr"] = $errstr;
        return $result;
        }

        fputs($socket, $reqheader);

        while (!feof($socket) ) {
        $result[] = fgets($socket, 4096);
        }

        fclose($socket) ;

        return $result;

        }

        ?> [/php]USING THE FUNCTION:[php]<?php

        $data["foo"] = "some";
        $data["bar"] = "data";

        $result = post_it($data, "http://www.zend.com/test/test.php3");

        if (isset($result["errno"])) {
        $errno = $result["errno"];
        $errstr = $result["errstr"];
        echo "<B>Error $errno</B> $errstr";
        exit;
        } else {

        for($i=0;$i< count($result); $i++) echo $result[$i];

        }

        ?> [/php]
        Source: http://www.zend.com/zend/spotlight/mimocsumissions.php

        But like I said, I was looking for an elegant solution.

        So, do you understand my unhappiness at your response?

        Good luck in your endeavors.
        Ron.

        Comment

        Working...