cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Post Any Form / Unknown fields

From: Stephen Pynenburg <spynenburg_at_gmail.com>
Date: Sun, 28 Feb 2010 14:49:20 -0500

So it's : 1) User posts form on your page 2) Your page forwards data to
remote script?
If you're sure that it is working with simple forms, it could be that some
forms being passed have array elements in the POST, so a simple $key=$value
wouldn't work - try adding an is_array check then loop through any arrays,
adding $key."[]"=$value[$i].

-Stephen

On Wed, Feb 24, 2010 at 19:14, William Crandell <
william+curl_at_webwizardwill.com <william%2Bcurl_at_webwizardwill.com>> wrote:

> 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
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-02-28