/    Sign up×
Community /Pin to ProfileBookmark

simple form/variable question

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 [i]form.php[/i] and the submit page is called [i]submit.php[/i]. submit.php mails the contents of the form.

on form.php there are a few form elements which are check boxes.

[code]<input type=’checkbox’ name=’newsletter’ value=’Yes’ checked>[/code]

If the box is unchecked, and you press the submit button on form.php, the next page will have [b]Notice: Undefined variable: newsletter in pathtothefilecalledsubmit.php on line 15[/b]. [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.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@pyroDec 02.2003 — 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
Copy linkTweet thisAlerts:
@hammerslaneauthorDec 02.2003 — thanks!

you know, one day i might stop asking stupid php questions
Copy linkTweet thisAlerts:
@pyroDec 02.2003 — lol... don't worry about it. Everyone has to go through the learning process. ?
×

Success!

Help @hammerslane spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...