By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,461 Members | 1,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,461 IT Pros & Developers. It's quick & easy.

Problem using curl_setopt for redirection

P: n/a
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_POSTFIELDS,
"amtsgericht=&dateYear=2004&monthsNr=&registerart= ".
"&cursorStepValue=5&orderby=Handelsregister-Nr.".
"&suchword=kastenholz&s=1&search=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
bn*****@g214mx.net
(remove numbers to despam)

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Marek Möhling wrote:
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.


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

Jul 17 '05 #2

P: n/a
> 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)
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_globals eventually...)
or by putting the arguments in a form that auto-submits (e.g. with
JavaScript).
Yes, but this is unconvenient when JS is turned off and wouldn't allow to be
triggered by cronjobs.
What you are trying to do can only be achieved...

I still hope that the header() function provides a solution.
Marek

bn*****@g214mx.net
(remove numbers to despam)

Jul 17 '05 #3

P: n/a
Thinking again, this:
...and wouldn't allow to be triggered by cronjobs... was not so well thought of me

But: so I guess the GET option is unintentional and can't
be relied on. (they might turn off register_globals eventually...)

is still a valid concern
Marek

bn*****@g214mx.net
(remove numbers to despam)
Jul 17 '05 #4

P: n/a
Thinking again again, it really can't be done as I'd like it to...:-(
M
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.