Reply to Re: [PHP] radio buttons in $_POST

Your name:

Reply:


Posted by Janet Valade on 04/23/05 22:56

Ashley M. Kirchner 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.)
>


One way would be to have a selection "None" and have it selected by
default. As in,

None <input type="radio" checked name="radio_test" value="None" />

Or you can just do something like,

<?php
if(!isset[$_POST['radio_test']))
echo "radio_test = none\n";
foreach ($_POST as $key => $val)
echo "$key = $val\n";
?>


Janet



--
Janet Valade -- janet.valade.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация