I have a forms site that has several fields and 2 radio buttons for gender (male/female).
In the PHP code I have a check to make sure all fields are filled in or selected. This part works. I have tested it with filling in all fields but one (for every field) and it recognizes when one isn't selected.
The problem is when I try to display the $_POST so the user can see what isn't filled in.
This is the PHP code.
echo "<pre>"
print_r($_POST);" command to display the
echo "</pre>"
Here are 2 examples of what comes out. They're self explanitory.
Array
(
[firstName] => ghj
[lastName] => gf
[church] => hgs
[youthLeader] => hds
)
Array
(
[firstName] => ghj
[lastName] =>
[gender] => male
[church] => hgs
[youthLeader] => hds
)
As you can see, the first one will not show that 'gender' is blank but it will show that the string variables are blank.
Any ideas why this would be?
Forms radio button not displaying
Moderator: General Moderators
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
FYI, fields will always be submitted even if it's blank. You have to do more validation than you did. For example...
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
God bless.
)&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "e;Lastname field not filled in."e;;
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
God bless.
ed[/color]>
<input type=radio value='female'>
God bless.
more validation than you did. For example...
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
God bless.
check if variable set or filled in
if(isset($_POST['lastname'])&&$_POSTї'lastname']!='')
$lastname = $_POSTї'lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "e;Lastname field not filled in."e;;
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
God bless. 
Code: Select all
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";Code: Select all
<input type=radio value='male' [color=red]checked[/color]>
<input type=radio value='female'>$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "e;Lastname field not filled in."e;;
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
Code: Select all
<input type=radio value='male' [color=red]checked[/color]>
<input type=radio value='female'><input type=radio value='female'>
God bless.
Code: Select all
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";Code: Select all
<input type=radio value='male' [color=red]checked[/color]>
<input type=radio value='female'>if(isset($_POST['lastname'])&&$_POSTї'lastname']!='')
$lastname = $_POSTї'lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "e;Lastname field not filled in."e;;
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
Code: Select all
<input type=radio value=e to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted iflways be submitted even if it's blank. You have to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
[code]
<input type=radio value='male' [color=red]checked[/color]>
<input type=radio value='female'>
[/code]
God bless. :wink:do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option if it's blank. You have to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
[code]
<input type=radio value='male' їcolor=red]checkedї/color]>
<input type=radio value='female'>
[/code]
God bless. :wink:lways be submitted even if it's blank. You have to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
[code]
<input type=radio value='male' їcolor=red]checkedї/color]>
<input type=radio value='female'>
[/code]
God blese']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are f it's blank. You have to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default oyou did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
[code]
<input type=radio value='male' їcolor=red]checkedї/color]>
<input type=radio variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. Avalidation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of thlways be submitted even if it's blank. You have to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
[code]
<input type=radio value='male' їcolor=red]checkedї/color&did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of lways be submitted even if it's blank. You have to do more validation than you did. For example...
[php]
// check if variable set or filled in
if(isset($_POST['lastname'])&&$_POST['lastname']!='')
$lastname = $_POST['lastname'];
else
$lastname = '';
// if not tell the user
if($lastname=='')
echo "Lastname field not filled in.";
[/php]
Now radioboxes are different, for it will not be submitted if the user didn't select any of them. And it is wise to choose one of them to be the default option.
[code]
<input type=radio value='male' їcolor=red]checkedї/color]>
<input type=radio value='female'>