Problem using curl_setopt for redirection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marek Möhling

    Problem using curl_setopt for redirection

    I'd like to redirect visitors to a remote location sending post values.


    Using:

    =============== =============== =============== =============== ====
    $ch = curl_init();
    curl_setopt($ch , CURLOPT_URL,
    "http://www.ihk-bonn.de/handelsregister/");
    curl_setopt($ch , CURLOPT_POST, 1);
    curl_setopt($ch , CURLOPT_POSTFIE LDS,
    "amtsgericht=&d ateYear=2004&mo nthsNr=&registe rart=".
    "&cursorStepVal ue=5&orderby=Ha ndelsregister-Nr.".
    "&suchword=kast enholz&s=1&sear ch=www.ihk-bonn.de");
    curl_exec($ch);
    =============== =============== =============== =============== ====

    I can retrieve www.ihk-bonn.de's response and print it to the browser, (see
    www.peterkastenholz.de/test.php) but what I want is to redirect to
    "www.ihk-bonn.de/handelsregister/" with my POST values and the corresponding
    result.

    I couldn't find code to do this on
    www.php.net/manual/en/function.curl-exec.php or curl.haxx.se etc.

    Using fsockopen/fputs directly didn't help - same result. Output
    buffering prevented the result from being printed to the browser, but I
    couldn't fiddle a redirection.

    Any clues?
    Marek


    bn548mm@g214mx. net
    (remove numbers to despam)



  • Janwillem Borleffs

    #2
    Re: Problem using curl_setopt for redirection

    Marek Möhling wrote:[color=blue]
    > I can retrieve www.ihk-bonn.de's response and print it to the
    > browser, (see www.peterkastenholz.de/test.php) but what I want is to
    > redirect to "www.ihk-bonn.de/handelsregister/" with my POST values
    > and the corresponding result.
    >[/color]

    What you are trying to do can only be achieved by either passing the
    arguments to the target host through a Location header (the host should
    accept GET requests in this case) or by putting the arguments in a form that
    auto-submits (e.g. with JavaScript).


    JW



    Comment

    • Marek Möhling

      #3
      Re: Problem using curl_setopt for redirection

      > What you are trying to do can only be achieved by either passing the[color=blue]
      > arguments to the target host through a Location header (the host should
      > accept GET requests in this case)[/color]

      Actually the host in question accepts both POST and GET, but it's form is
      set to method="POST", so I guess the GET option is unintentional and can't
      be relied on. (they might turn off register_global s eventually...)
      [color=blue]
      > or by putting the arguments in a form that auto-submits (e.g. with
      > JavaScript).[/color]

      Yes, but this is unconvenient when JS is turned off and wouldn't allow to be
      triggered by cronjobs.
      [color=blue]
      > What you are trying to do can only be achieved...[/color]
      I still hope that the header() function provides a solution.


      Marek

      bn548mm@g214mx. net
      (remove numbers to despam)





      Comment

      • Marek Möhling

        #4
        Re: Problem using curl_setopt for redirection

        Thinking again, this:[color=blue]
        > ...and wouldn't allow to be triggered by cronjobs...[/color]
        was not so well thought of me

        But:[color=blue]
        > so I guess the GET option is unintentional and can't
        > be relied on. (they might turn off register_global s eventually...)[/color]
        is still a valid concern


        Marek

        bn548mm@g214mx. net
        (remove numbers to despam)


        Comment

        • Marek Möhling

          #5
          Re: Problem using curl_setopt for redirection

          Thinking again again, it really can't be done as I'd like it to...:-(
          M


          Comment

          Working...