Re: multiple select form elements question
| From: | Pushkar Pradhan | Date: | Thu, 09 May 2002 15:49:42 +0000 |
| Subject: | Re: multiple select form elements question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96824@lists.php.net to get a copy of this message | ||
Ravi,
I am doing exactly the same kind of form processing and getting the
desired results (apache 1.3.22!).
> Unless you really know what you are doing, I would suggest not using
> Apache2 yet. Apache2+PHP is really not fully baked at this point.
>
> Downgrade to the stable Apache1 and this will work as you expect.
>
> -Rasmus
>
> On Thu, 9 May 2002, ravi wrote:
>
> >
> > hello,
> >
> > i am a PHP newbie and i am stumped by the problem below and
> > would appreciate any thoughts:
> >
> > if i am submitting my HTML form to a PHP script, i am asked to do
> > something like the below, for multiple selection elements:
> >
> > HTML file:
> >
> > <form action="test.php" method="post">
> > <select name="testvar[]" multiple>
> > <option>opt1</option>
> > <option>opt2</option>
> > <option>opt3</option>
> > <option>opt4</option>
> > <option>opt5</option>
> > </select>
> > <br>
> > <input type="submit">
> > </form>
> >
> > then, in my test.php i am supposed to be able to access these
> > form elements using the $_POST global. that works for non-
> > -multiple choice elements, but for multiple choice elements such
> > as the above the values are repeated!
> >
> > for example, if i chose "opt1" and "opt2" above, and in the PHP
> > script i access it as below:
> >
> > $_POST['testvar']
> >
> > then the array that is returned by the above access has 4 elements
> > not 2!
> >
> > count($_POST['testvar']) => 4
> > $_POST['testvar'] => ('opt1', 'opt2', 'opt1',
> > 'opt2')
> >
> > sometimes things get even worse with the value of a hidden
> > element being added to one of these arrays!
> >
> > could it be the browser messing up on encountering the '[]'? i have
> > tested on mozilla-1.0rc1 and netscape-4.7. i am running apache2
> > with php4 on freeBSD 4.3.
> >
> > any ideas?
> >
> > thanks,
> >
> > --ravi
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
-Pushkar S. Pradhan