PHP/CGI form processing with same-named checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rob3139
Forum Newbie
Posts: 3
Joined: Wed Oct 15, 2008 9:11 am

PHP/CGI form processing with same-named checkboxes

Post by rob3139 »

Dear All,

Bit of a headscratcher this one - I hope you guys can help.

I'm trying to process a form automatically using PHP and CURL. It all goes fine until there are multiple checkboxes with the same name, eg.

<input type="checkbox" name"cb1" value="1" />
<input type="checkbox" name"cb1" value="2" />

Now the form is actually processed using a CGI script that I don't have access too. I'm passing the form variables to the cgi script using PHP & CURL. But because PHP can't cope with same-named checkboxes without an array attached (ie. cb1[]), and attaching the array confuses the CGI script, I'm stuck.

Anyone got any idea how I can get the scripts to talk to each other?

Thanks in advance,

Rob
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: PHP/CGI form processing with same-named checkboxes

Post by aceconcepts »

Why do they have to have the same names?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: PHP/CGI form processing with same-named checkboxes

Post by papa »

Multible <select> maybe?
rob3139
Forum Newbie
Posts: 3
Joined: Wed Oct 15, 2008 9:11 am

Re: PHP/CGI form processing with same-named checkboxes

Post by rob3139 »

Thanks for your quick replies. The problem is I cannot change the form (or the CGI script) - they are part of the system I am trying to automate using CURL. So I'm stuck with the form.

Any ideas??

Thanks again,

Rob
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: PHP/CGI form processing with same-named checkboxes

Post by papa »

What do you want the checkboxes to pass?

If the script gets confused by an array, in what format would you pass the same named variable with different values without overwriting?
rob3139
Forum Newbie
Posts: 3
Joined: Wed Oct 15, 2008 9:11 am

Re: PHP/CGI form processing with same-named checkboxes

Post by rob3139 »

That's exactly my question - is there any way I can get the variables to the CGI script via PHP in a way the CGI script would understand them?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: PHP/CGI form processing with same-named checkboxes

Post by papa »

It sounds pretty hard if you can't edit the form or the cgi script m8. :P

With a multiple select for example, you could convert the data to a string with php and then pass it on.
Post Reply