Post Any Form / Unknown fields

William Crandell <[email protected]>
Newsgroups gmane.comp.web.curl.php
Message-ID <[email protected]>
I have been trying to figure out a way to post different forms.  I
explicitly trust the remote server and want to be able to use cURL to
display the remote site to the client.   I also want all the forms to work.
 Well some of the forms work while others don't.
The main feature I am trying to achieve is allowing the 3rd party server to
change their forms/fields without notice to me, while maintaining a working
cURL based web app.
The source line that I am currently using does not work 100%.  At least it
eludes me as to why my current script works on some forms and not others.
 Anyhow on to the code:

################################
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $fileUrl );
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $Cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie);
if (isset($_POST)) {
  foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
    }
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
}
$homepage = curl_exec ($ch) or die ("Couldn't connect to $fileUrl1.");
curl_close ($ch);
echo = $homepage;
################################

Any suggestions?

Of course I have a few other things happening before and after, though I am
sure the problem exists within the above code.
Thanks.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.