Re: radio buttons in $_POST
| From: | M Saleh EG | Date: | Sat, 23 Apr 2005 19:43:08 +0000 |
| Subject: | Re: radio buttons in $_POST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-213738@lists.php.net to get a copy of this message | ||
That's because Radio Buttons and Check Boxes do not return anything if not
checked or selected.
So you gotta explicitly do it ur self. That is u gotta check for it's
validity and non-empiness.
e.g. in ur scenario
if(!isset($_POST['radio_test'])) { //print out all the options unselected }
else
{ // print the value and show the rest empty in the report }
On 4/23/05, Ashley M. Kirchner <ashley@pcraft.com> wrote:
>
>
> I have this form.html:
>
> <form method="post" action="form.php">
> text input <input type="text" name="input_test"><br />
> radio input1 <input type="radio" name="radio_test"
> value="test1" />
> radio input2 <input type="radio" name="radio_test"
> value="test2" />
> <input type="submit" value="Submit">
> </form>
>
> Then I have this script (form.php):
>
> <?php
> foreach ($_POST as $key => $val)
> echo "$key = $val\n";
> ?>
>
> If I simply submit the form empty, all I get back from the script is
> the text input $key. The radio button doesn't show up. Why is that and
> how can I have it show up? (the radio input does show up once one of
> the radios is checked, but I need it to show up when empty as well.)
>
> --
> H | I haven't lost my mind; it's backed up on tape somewhere.
> +--------------------------------------------------------------------
> Ashley M. Kirchner <mailto:ashley@pcraft.com> .
> 303.442.6410 x130
> IT Director / SysAdmin / WebSmith . 800.441.3873 x130
> Photo Craft Imaging . 3550 Arapahoe Ave. #6
> http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
M.Saleh.E.G
97150-4779817