Forum Moderators: coopster
On the second page I have the following code:
if($_POST['nonprofit']=='1'){
$nonprofit='1';
}else{
$nonprofit='0';
}
And in the body I have the folowing:
THE VALUE FOR nonprofit is <? echo $nonprofit;?>
When nonprofit is checked I get:
THE VALUE FOR nonprofit is 1
Which is what I expected. However when nonprofit is not checked I get the following:
Notice: Undefined Index: nonprofit ...etc.
THE VALUE FOR nonprofit is 0
The line that the notice refers to is:
if($_POST['nonprofit']=='1'){
I am a little confused by this error , since the ouput is what I wanted, so the if statement is working. Can anyone help me out with this.
therefore
if($_POST['nonprofit']=='1'){
trips the undefined index notice
but this
if(!isset($_POST['nonprofit']) ¦¦ $_POST['nonprofit']=='1'){
would handle both cases
note: WebmasterWorld breaks pipes the ¦ must be replaced with a real pipe character
if(!isset($_POST['nonprofit'])){
$nonprofit='0';
}else{
$nonprofit='1';
}
Thanks for the help. As always, this site is a help. I don't think there has been a single post I have put on here that has gone unsolved.