473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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_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
4 1905
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
> 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
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
Thinking again again, it really can't be done as I'd like it to...:-(
M
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jochen Daum | last post by:
Hi, I'd like to pass through an Excel file from one server, (one secret password) to a user (different passwords). I thought I had duplicated the headers: $ch = curl_init();...
0
by: chad.arimura | last post by:
Hey all, I've been trying to write a short script using curl w/ php but can't figure something out: I'm simply trying to login to a website using a posted user/pass combo to an html form...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
4
by: zorro | last post by:
Hello there, I can't figure out why is it that when i use an array for my postfields it doesn't work : this works curl_setopt($curl, CURLOPT_POSTFIELDS, "clown=bozo" ); this doesn't...
1
by: csteimonts | last post by:
Hey there, if it would be possible, since you have figured out the login function of logging into yahoo from PHP CURL, could you post that solution? I'm having quite a time figuring that...
4
by: sandeept | last post by:
Hello, I am trying to access a website which is hosted on secure server. Code looks as follows, <?php //open connection $ch = curl_init(); //set the url, number of POST vars,...
1
by: swethak | last post by:
Hi, i used the curl_init() function in my application. function exchangeToken($token) { $ch = curl_init(); /* Create a CURL handle. */ curl_setopt($ch,...
3
by: buzz2050 | last post by:
Hi all, I am using cURL for the first time. I need to login to a site and my cURL code to do the same is as follows: //curlScript.php <?php function getContent($url, $referer,...
3
by: jeddiki | last post by:
I am using curl to down load a zip file and I am then trying to unzip it, but I don't think that I am using the functions properly because I get warnings This is my code: <?php if...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.