Avatar billede crunch Nybegynder
16. marts 2001 - 17:35 Der er 1 løsning

get > post script

Jeg kan simpelt hen ikke få det til at virke.. Arghh.

Hvordan sætter man adressen:

http://job.ofir.dk/default.asp

og formen:

name=\"search\" value=$variabel

ind i dette script så det virker.. ????


<?php
/************************************************************************
*
* PostIt - Pretend to be a form.
*
* Copyright (c) 1999 Holotech Enterprises. All rights reserved.
* You may freely modify and use this function for your own purposes. You
* may freely distribute it, without modification and with this notice
* and entire header intact.
*
* This function takes an associative array and a URL. The array is URL-
* encoded and then POSTed to the URL. If the request succeeds, the
* response, if any, is returned in a scalar array. Outputting this is the
* caller\'s responsibility; bear in mind that it will include the HTTP
* headers. If the request fails, an associative array is returned with the
* elements \'errno\' and \'errstr\' corresponding to the error number and
* error message. If you have any questions or comments, please direct
* them to postit@holotech.net
*
*                                          Alan Little
*                                          Holotech Enterprises
*                                          http://www.holotech.net/
*                                          December 1999
*
************************************************************************/

  function PostIt($DataStream, $URL) {

//  Strip http:// from the URL if present
    $URL = ereg_replace(\"^http://\", \"\", $URL);

//  Separate into Host and URI
    $Host = substr($URL, 0, strpos($URL, \"/\"));
    $URI = strstr($URL, \"/\");

//  Form up the request body
    $ReqBody = \"\";
    while (list($key, $val) = each($DataStream)) {
      if ($ReqBody) $ReqBody.= \"&\";
      $ReqBody.= $key.\"=\".urlencode($val);
    }
    $ContentLength = strlen($ReqBody);

//  Generate the request header
    $ReqHeader =
      \"POST $URI HTTP/1.1\\n\".
      \"Host: $Host\\n\".
      \"User-Agent: PostIt\\n\".
      \"Content-Type: application/x-www-form-urlencoded\\n\".
      \"Content-Length: $ContentLength\\n\\n\".
      \"$ReqBody\\n\";

//  Open the connection to the host
    $socket = fsockopen($Host, 80, &$errno, &$errstr);
    if (!$socket) {
      $Result[\"errno\"] = $errno;
      $Result[\"errstr\"] = $errstr;
      return $Result;
    }
    $idx = 0;
    fputs($socket, $ReqHeader);
    while (!feof($socket)) {
      $Result[$idx++] = fgets($socket, 128);
    }
    return $Result;
  }
?>




Avatar billede crunch Nybegynder
16. marts 2001 - 19:08 #1
virker nu !
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester