The form contains a typical radio button group with none checked. The values in the form are passed to a PHP handler page.
Problem: if none of the radio buttons are selected, the following error is displayed:
Notice: Undefined index: ServDogType in C:\web\Keystone\www2\ssd\prelimappHandler.php on line 68
This is the code from line 68:
$ServDogType = trim($_POST["ServDogType"]);
All of the other form values are accepted. As well, if a radio button IS checked, no error is displayed.
Any ideas, good people?
Thanks very much for your help!
Pat
If no radio btn is selected, get Undefined Index error
Moderator: General Moderators
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
state, college, huh?
I think if hte radio button is unchecked, it posts nothing, so the index in the $_POST array which you are referring too does not exist. Verify the $_POST data. Either check it with isset or use javascript to ensure the form is not posted until all items are filled out.
a quick fix is to place the above line in an if block:
if(isset($_POST["ServDogType"]){
$ServDogType = trim($_POST["ServDogType"]);
}
I think if hte radio button is unchecked, it posts nothing, so the index in the $_POST array which you are referring too does not exist. Verify the $_POST data. Either check it with isset or use javascript to ensure the form is not posted until all items are filled out.
a quick fix is to place the above line in an if block:
if(isset($_POST["ServDogType"]){
$ServDogType = trim($_POST["ServDogType"]);
}
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
-
pbritten
- Forum Newbie
- Posts: 13
- Joined: Wed Mar 24, 2004 9:24 am
- Location: State College, Pennsylvania, USA
Understood
Magic: yes, I understand.
Thanks again!
Thanks again!