Skip navigation
Currently Being Moderated

checkbox in php mailform

May 23, 2012 2:43 PM

Tags: #checkbox

Hello Dreamweavers

 

I am working on a new site which has a contactform to send an e-mail.

This works fine

form has the following fields: name, email, phone, website, subject and message

 

site is here: http://tinyurl.com/7vzgl7z

 

I now want to add a checkbox that people can check if they want to receive a "questionnaire"

 

I added this to my form like so:

 

<label for="questionnaire">Yes, please send me the questionnaire</label>

<input type="checkbox"  id="questionnaire" name="questionnaire" value="yes">

 

The mail is then send by the send.php file like so:

 

 

$post = (!empty($_POST)) ? true : false;

 

          if($post)

          {

                    $name            = stripslashes($_POST['name']);

                    $email            = trim($_POST['email']);

                    $phone = stripslashes($_POST['phone']);

                    $website = stripslashes($_POST['website']);

                    $subject = stripslashes($_POST['subject']);

                    $message = stripslashes($_POST['message']);

 

                    $error = '';

 

// some more code

 

My question is how to get the checkbox value to be sent to my e-mail

I found some examples on the web, but still can't get it to work.

 
Replies
  • Currently Being Moderated
    May 23, 2012 11:25 PM   in reply to EagerBob

    Should simply be $questionnaire= $_POST['questionnaire'];

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points