Re: questions about if statements regarding a checkbox
| From: | Adam Richardson | Date: | Sun, 31 Oct 2010 02:23:39 +0000 |
| Subject: | Re: questions about if statements regarding a checkbox | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309157@lists.php.net to get a copy of this message | ||
On Sat, Oct 30, 2010 at 10:05 PM, Ben Brentlinger <Ben@benbrent.com> wrote:
> hello,
>
> I'd like to know the proper code to use in a php script that processes a
> form with a checkbox in order to send one email if the checkbox has been
> checked and another email if the checkbox hasn't. I tried if($check ==
> true) and I tried putting the word "true" in double quotes, and both of them
> caused the "unexpected variable" syntax error. The only problem is, all I
> could think to use was that line of code I just used, I'm not sure what the
> proper syntax is for checkbox when using the if statement to send one email
> when the checkbox is checked and a different email when it's not checked.
> I'm wanting to send an email to the site admin with the information given
> by the person who filled out the form that contains the checkbox.
>
// checkboxes are only set if checked
if (isset($_GET['checkbox_name'])) {
// checkbox is checked, so send one mail
mail($to = 'one@email.com', $subject = 'Really cool email');
} else {
// checkbox isn't checked, so send a different email
mail($to = 'different@email.com', $subject = 'Just as cool email');
}
Adam
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com