I can't get any of my attempts to validate the radio button to work. If either of the buttons is clicked it works. But, if no button is clicked an the submit button is click by itself I get an error on my action page. I'm out of ideas and tired of searching the web.

Here's my recent code.

<html>
<p align="center">
<form action = "login.php" method = "post">
<?php $menu = "Unchecked" ?>
Administrator:
<input name = "menu" type="radio" value="Administrator" >
Member :
<input name = "menu" type="radio" value="Member" ><br><br>
<input type='submit' value = 'Select a Radion Button'>
<?php
if (isset($_POST)) {
<input name = "menu" type="radio" value="blank" >
die ("You need to check one of the radio buttons!");
}
?>
</html>

I can't get any of my attempts to validate the radio button to work. If either of the buttons is clicked it works. But, if no button is clicked an the submit button is click by itself I get an error on my action page. I'm out of ideas and tired of searching the web.

Here's my recent code.

<html>
<p align="center">
<form action = "login.php" method = "post">
<?php $menu = "Unchecked" ?>
Administrator:
<input name = "menu" type="radio" value="Administrator" >

Member :
<input name = "menu" type="radio" value="Member" ><br><br>
<input type='submit' value = 'Select a Radion Button'>
<?php
if (isset($_POST)) {
<input name = "menu" type="radio" value="blank" >
die ("You need to check one of the radio buttons!");
}
?>
</html>

try this

<?
ob_start();
extract($_POST);
if($_POST)
{
echo $menu;exit;
header('location:login.php?menu=$menu');
}
?>
<html>
<p align="center">
<form action = " " method = "post">

Administrator:
<input name = "menu" type="radio" value="Administrator" >
Member :
<input name = "menu" type="radio" value="Member" ><br><br>
<input type='submit' value = 'Select a Radion Button'>

</html>

try this

<?
ob_start();
extract($_POST);
if($_POST)
{
echo $menu;exit;
header('location:login.php?menu=$menu');
}
?>
<html>
<p align="center">
<form action = " " method = "post">

Administrator:
<input name = "menu" type="radio" value="Administrator" >
Member :
<input name = "menu" type="radio" value="Member" ><br><br>
<input type='submit' value = 'Select a Radion Button'>

</html>

This works but I still need to activate different pages if the respective radio buttons are clicked. That is, I need to direct the user to a login page from the radio button page, which I can get to work but the problem I encounter is an "undefined index" error if the submit button is clicked without clicking a radio button first.

try this.

<html>
<p align="center">
<form action = "login.php" method = "post">

Administrator:
<input name = "menu" type="radio" value="Administrator" >
Member :
<input name = "menu" type="radio" value="Member" ><br><br>
<input type='submit' value = 'Select a Radion Button'>
</form>
</html>

in login.php.

<?
extract($_REQUEST);
echo $menu;exit;
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.