Submit form with PHP cURL, multiple checkboxes with same name -


i trying submit external form using php curl. form fields working fine, except problem have multiple checkboxes same name.

<input type="checkbox" name="same_name" value="value_1"> <input type="checkbox" name="same_name" value="value_2"> <input type="checkbox" name="same_name" value="value_3"> 

i have no problem passing 1 of checkboxes in curl request. in post string, do:

curl_setopt($ch, curlopt_postfields, '...&same_name=value_1'); 

but now, want submit form multiple boxes checked. tried suggestion in comments on this stackoverflow post:

curl_setopt($ch, curlopt_postfields, '...&same_name[]=value_1&same_name[]=value_2'); 

but response based on no checked checkboxes @ all, ergo doesn't work.

basically, how can submit such array correctly in request? can point me in right direction?

if it's form (you can change code), change checkbox's name same_name[]

<input type="checkbox" name="same_name[]" value="value_1"> <input type="checkbox" name="same_name[]" value="value_2"> <input type="checkbox" name="same_name[]" value="value_3"> 

and call curl_setopt($ch, curlopt_postfields, '...&same_name[]=value_1&same_name[]=value_2');, it's ok.

if it's external - can't have multiple choice.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -