Re: Re: [PHP] how to use echo checkboxes in php when i don't have access to $_POST

From: Date: Sat, 28 May 2011 15:48:00 +0000
Subject: Re: Re: [PHP] how to use echo checkboxes in php when i don't have access to $_POST
Groups: php.general 
Request: Send a blank email to php-general+get-313211@lists.php.net to get a copy of this message
On 28 May 2011 at 14:11, Igor Konforti <php.net@confiq.org> wrote: > It means that array $_POST does not have a key called "negin". > Simple If statement before line 4 would fix this. > On Sat, May 28, 2011 at 16:03, Negin Nickparsa <nickparsa@gmail.com> wrote: >> suppose that i have this SIMPLE code: >> <?php >> echo"<input type='Checkbox' name='negin' value='yes' >> checked />"; >> echo $_POST['negin']; >> ?> >> <html> >> <head> >> <body> >> <form method="post"> >> </form> >> </body> >> </head> >> </html> >> error is this: >> Undefined index: negin in *D:\phpweb\negin2.php* on line *4* >> * >> * >> *how can I correct this?* For one thing you need to have the PHP code inside the <form></form>. Second you don't need to echo the <input>, just write that straight into the HTML. And you need to use the isset() function so you don't try to echo $_POST['negin'] unless it it is set. -- Cheers -- Tim

« previous php.general (#313211) next »