KiloJKilo
KiloJKilo

Reputation: 485

PHP post array and a curl submission

I have built a form submission consisting of about 90 values. The form needs to be submitted to another page that has a curl session which handles the last part. My question is, when I submit that form, how do I access the $_Post[] data as a whole array so I can submit it as the curl post array?

need to get

<form name="send" action="process.php" method="post">
<input 1>
<inpit 2>
...
<input 90>
</form>

to

process.php :

curl_setopt( $ch, CURLOPT_POSTFIELDS, $_Post[] );

Or is it as easy as putting $Post[]?

Upvotes: 2

Views: 570

Answers (1)

newfurniturey
newfurniturey

Reputation: 38416

From the manual, the CURLOPT_POSTFIELDS value can be in a query-string format, var1=value1&var2=value2... or in an array format with the key being the field name, such as you have with $_POST.

You are currently using $_POST[] in your example; drop the [] and it should work fine:

curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);

Upvotes: 1

Related Questions