How do you pass checkbox info

I am writing a simple mail script where I have the information that is filled out in a form sent via email to a recipient.

I just don’t know how to say, if isset so that if the checkbox is checked to send that information along via email

Here is what I got so far:

    $body = "First Name:   " . $_POST['first_name'] . "<br><br>";

    $body .= "Last Name:   " . $_POST['last_name'] . "<br><br>";

    $body .= "Email:   " . $_POST['email'] . "<br><br>";
    $body .= "Phone Number:   " . $_POST['area_code,phone,phone_ext'] . "<br><br>";
    $body .= "Consumer Playing Cards:   " . $_POST['services'] . "<br><br>";
    $body .= "Professional Casino Cards:   " . $_POST['services'] . "<br><br>";
    $body .= "Accessories:   " . $_POST['services'] . "<br><br>";
    $body .= "Other Questions:   " . $_POST['services'] . "<br><br>";
    $body .= "Subject:   " . $_POST['subject'] . "<br><br>";
    $body .= "Questions:   " . $_POST['Questions'] . "<br><br>";

    $to = "xxxx@xxxx";
    $from = "xxxxxxx";
    $subject = "Contact Us Form";
  $headers  = "From: $from\\r\
  $headers .= "Content-type: text/html\\r\

    mail($to, $subject, $body, $headers);

Thanks for any help or advice on this,


wait!!! One last question

Ok, so I got that I need in there If Isset so I put this on the top of the page

if(isset($_POST[‘consumer_playing_cards’]) && $_POST[‘consumer_playing_cards’] == ‘yes’) {


but what do I do to show it pass to the email or is the isset go in the .body part?

Cause when I put the mailto part in there as $body .= 'Consumer Playing Cards: ’ . $_POST[‘consumer_playing_cards’] . “<br><br>”;

It just shows consumer_playing_cards when the email comes over.

What am I missing here on this?

Thanks for any help,

Thanks Guys for all your help,

this sets me in the right direction at least to figuring what I have to do…


If you have an HTML that defines a checkbox like this:

<input type="checkbox" name="chbox" value="1" />

you access the checkbox and its value in php like this:

$chbox_value = isset($_POST['chbox']) ? false : $_POST['chbox'];

The usual method of checking whether a checkbox was checked is using isset() function, such as


Of course, having a lot of checkboxes makes this process rather tiresome (and it’s bad coding practice) so there are alternatives. However, Anthony’s example and this example should put you on the right track solving your problem.

checkbox values are sent to the server side script only if they are checked.

I would also give the checkbox a value as well in the form although it’s not mandatory

<input type="checkbox" name="chkSendEmail" value="yes" />

and then in the php script

if(isset($_POST['chkSendEmail']) && $_POST['chkSendEmail'] == 'yes') {
//send the email

Let me see if I can help. :slight_smile:

if(true === array_key_exists('checkbox_name', $_POST)){
    #mail it

Actually, Never mind that last post of ramblings… it is end of day for me and I tend to just blurt out things I don’t understand. LOL

I got it working now

Thanks again for all your help,