Re: Notice: Undefined index: op

From: Date: Tue, 22 Feb 2005 16:51:42 +0000
Subject: Re: Notice: Undefined index: op
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38636@lists.php.net to get a copy of this message
Notices have been turned on your PHP installation. This means you will need to declare all of your variables otherwise you will receive a notice. To fix your problem simply declare your POST variable before use. if(isset($_POST['op'])) { $op = $_POST['op']; } else { $op = ""; } if($op != 'ds') { etc.......
I get the error message: *Notice*: Undefined index: op When trying to set up a form. I have looked everywhere for the solution. I don't understnadn how to define that index. The come it comes from is: if ($_POST['op'] != 'ds') { $display_block = " <form action=\"$_SERVER[PHP_SELF]\" method=\"POST\"> Your E-mail Address: <input type=text name=\"email\" size=40 maxlength=150/> <input type=radio name=\"action\" value=\"sub\" checked/>subscribe<br/> <input type=radio name=\"action\" value=\unsub\" />unsubscribe <input type=\"hidden\" name=\"op\" value=\"ds\"/> <input type=submit name=\"submit\" value=\"Submit Form\"/> </form>"; } I am trying to create a form which allows my users to join a mailing list. I conceptually understand what the problem is but cannot find out how to solve the problem. I cannot find out how to define 'op'. Please do not tell me to lower my error reporting levels. I would rather fix the problems. Thank you, Joseph


« previous php.db (#38636) next »