You are here: Re: PHP newbie, help needed « All PHP « IT news, forums, messages
Re: PHP newbie, help needed

Posted by Neeper on 04/16/06 01:22

You need to create a string to attach to the end of your
https://www.myswebsite.com/receiving.php uri that will pass those
values.

The string would look like so:
https://www.myswebsite.com/receiving.php?name=data&name2=data2


So what you want to do is this to assemble the string ($p is what I
called it below), place it before the curl_init() line


foreach($_POST as $subarray)
{
list($foo, $bar) = $subarray;
$bar = urlencode($bar);
$p[] = "$foo=$bar";
}

$urlstr = join("\n", $p);
$p = ereg_replace("\n", "&", $urlstr);
// echo $p; // Uncomment this if you want to see the assembled string



Then change your to:


curl_setopt( $session, CURLOPT_POSTFIELDS, $p );


That should do it. Good luck!




On Wed, 12 Apr 2006 10:21:11 -0400, mickey
<miguelportillaATpobrosDOTcom@ignore.this> wrote:

>
>$ch should be $session in my code,I pasted incorrectly.
>
>mickey wrote:
>>
>> Hello,
>>
>> I am trying to post an array using cURL from one PHP page to another. I
>> can't figure out how to read the array on the page that actually
>> receives it. Here is what I have...
>>
>>
>> $session = curl_init();
>>
>> curl_setopt( $session, CURLOPT_URL,
>> "https://www.myswebsite.com/receiving.php" );
>>
>> curl_setopt( $session, CURLOPT_HEADER, false );
>> curl_setopt( $session, CURLOPT_POST, true );
>>
>> curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST['fields'] );
>>
>> curl_setopt( $session, CURLOPT_RETURNTRANSFER, true );
>> curl_setopt( $session, CURLOPT_SSL_VERIFYPEER, false );
>> curl_setopt( $session, CURLOPT_USERPWD, $sslpassword );
>> curl_setopt( $session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
>>
>> $returned = curl_exec( $ch );
>> curl_close( $ch );
>> echo $returned;
>>
>>
>>
>>
>> On the receiving page this echos zero ...
>>
>> $numFormFields = count( $_POST['fields'] );
>>
>>
>>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация