0

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>

2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by muralikalpana
0

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>

Edited by muralikalpana: n/a

0

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.

0

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;
?>

Edited by muralikalpana: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.