Click to See Complete Forum and Search --> : simple form/variable question


hammerslane
12-02-2003, 08:46 AM
this is a simple question, hopefully with an extremely easy answer which eludes me for reasons unknown
i have a site with a simple form
the form page is called form.php and the submit page is called submit.php. submit.php mails the contents of the form.

on form.php there are a few form elements which are check boxes.<input type='checkbox' name='newsletter' value='Yes' checked>If the box is unchecked, and you press the submit button on form.php, the next page will have Notice: Undefined variable: newsletter in \\path\to\the\file\called\submit.php on line 15. [line 15 is a line which includes the contents of the form, in a mail() function]
This variable problem only exists if the box is left unticked. Is there a way to get the form to pass a value for $newsletter through the browser, even if the box isn't ticked?

many thanks.

pyro
12-02-2003, 11:02 AM
There's no need to. Just check if the variable is set before trying to use it:

http://us2.php.net/manual/en/function.isset.php

hammerslane
12-02-2003, 11:19 AM
thanks!
you know, one day i might stop asking stupid php questions

pyro
12-02-2003, 01:30 PM
lol... don't worry about it. Everyone has to go through the learning process. :)