Re: HTTP_Clients and Files - Part 2
| From: | Andrew Nagy | Date: | Thu, 18 Nov 2004 20:45:32 +0000 |
| Subject: | Re: HTTP_Clients and Files - Part 2 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15654@lists.php.net to get a copy of this message | ||
Justin Patrin wrote:
On Wed, 17 Nov 2004 17:15:38 -0500, Andrew Nagy <asnagy@webitecture.org> wrote:Not if you use brackets in your element name, hence the useBrackets flag in HTTP_Client. example: <select name="user_id[]" multiple> <option value="1">Bob</option> <option value="2">Joe</option> <option value="3">Tom</option> <option value="4">Fred</option> </select> or <input type="checkbox" name="user_id[]" value="1"> Bob <input type="checkbox" name="user_id[]" value="3"> Joe <input type="checkbox" name="user_id[]" value="4"> Tom <input type="checkbox" name="user_id[]" value="5"> Fred If you use a bracket in your element name, PHP will convert it to an array. Similarly, in ASP you don't need to use an array, as it will automatically put commas (if i remember correctly) separating the values. Regardless, this is a very common practice and should be supported in XHTML otherwise many many web forms will become invalid. If XHTML does not support this, then there must be a work around due to the commonality of this practice. And according to Alexey, it is supported in HTTP_Client by using an array as a value for post data. AndrewJustin Patrin wrote:Well, with XHTML the input elements *should* use "id" instead of "name" and since ids must be unique this wouldn't be valid. In addition, languages such as PHP won't give you all of the values, just the last one.On Wed, 17 Nov 2004 15:12:33 -0500, Andrew Nagy <asnagy@webitecture.org> wrote:I would assume so. Have you never done this before? It's a very common practice.Justin Patrin wrote:Hmmm..is it valid for XHTML?On Wed, 17 Nov 2004 12:12:38 -0500, Andrew Nagy <asnagy@webitecture.org> wrote:Sure it is. Take a look at: http://www.w3.org/TR/html4/interact/forms.html#checkbox "Several checkboxes in a form may share the same control name. Thus, for example, checkboxes allow users to select several values for the same property. The INPUT element is used to create a checkbox control."Anyway, my new question is how do i send an array of data in a post or get method? For example, if the form that I am submitting to has a set of checkboxes that are all the same name. $client->post($url, array('sessionid' => 'abc123', 'options' => array('1', '3', '7')));Hmmm... It's not really HTML compliant to have multiple checkboxes with the same name. It *is* possible with HTTP_Request using addRawPostData. I don't know if it's possible with HTTP_Client.