Email form is not sendding my data from my radio button groups

the top part of the email form work i.e.name ,email, comments, but the data from my radio button is not being sent .

<fieldset id="subscribe">
            <h2> Subscribe to my newsletter?</h2>
            <p>
            <input name="subscribe" type="radio" value="Yes" id="subscribe-yes"
            <?php
			$OK = isset($_POST['subscribe']) ? true : false;
			if ($OK && isset($missing) && $_POST['subscribe'] == 'Yes'){ ?>
            checked="Checked"
            <?php } ?>
            />
            <label for="subscribe-yes">Yes</label>
            <input name="subscribe" type="radio" value="NO" id="subscribe-no"
            <?php
			if ($OK && isset($missing) && $_POST['subscribe'] == 'No') { ?>
            checked = "checked"
            <?php } ?>
            />
            <label for ="subscribe-no">No</label>
            <p>
            <fieldset id="interests">
            <h2>what can I help you with:</h2>
            <div>
            <p>
            <input type="checkbox" name="interests[]" value"Healthy" id="healing"
            <?php
			$OK = isset($_POST['interests']) ? true : false;
			if($OK && isset($missing) && in_array('Healthy', $_POST['interests'])){ ?>
            checked="checked"
            <?php } ?>
            />
            <label for="Weight Loss">Weight Loss</label>
            </p>
            <p>
            <input type="checkbox" name="interests[]" value="Life Coach" id="coach"
            <?php
			if($OK && isset($missing) && in_array('Life Coach',$_POST['interests'])){?>
            checked="checked"
            <?php } ?>
            />
            <label for="Life Coach">Life Coach</label>
            </p>
            </div>
            </fieldset> 
            <p><br>
                <input name="send" id="send" type="submit" value="Send Message">
            </p>

Open in new window

imagekrazyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Where are your FORM tags?
0
Ray PaseurCommented:
Radio buttons, like checkboxes, do not appear in the request at all if they are not fired.  This is in contrast to inuts of type="text" which appear but are empty.  

There may be a logic error in the script above.  Have you tried printing $_POST with var_dump()?
0
Kim WalkerWeb Programmer/TechnicianCommented:
What DOCTYPE are you using? If you're using X-HTML, the YES button will not be checked because the value of the checked attribute is case-sensitive and you have on line 8 above:
            checked="Checked"

Open in new window

The value should be all lower-case in X-HTML.
            checked="checked"

Open in new window

Ray_Paseur is right. This appears to be the second form in a series because it relies on $_POST values in order to check the radio buttons and checkboxes. But if the checkboxes are being reported correctly, that must not be the problem. Also, you should be able to see if the radio buttons are checked or not before you submit the form.

I'm with GaryC123, show us the form tag, too. Or even better, can you give us a url to the live page?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

imagekrazyAuthor Commented:
Hi,
and here is the test page

<!DOCTYPE HTML>
<head>
<title>summer rain wellness</title>

<link href="css/contactStyle.css" rel="stylesheet" type="text/css">
</head>
<body>

<div id="header">
    <h1>Summer Rain Wellness</h1>
</div>
<div id="wrapper">
<?php include('includes/menu.inc.php'); ?>

    <div id="maincontent">
      <h2>Contact Us </h2>
      <?php
	  if ($_POST && isset($missing) && !empty($missing)){
		  ?>
          <p class="warning">Please complete  the missing items(s) indicated.</p>
          <?php
	  }
	  elseif ($_POST && !$mailSent) {
		  ?>
          <p class="Warning">Sorry, there was problem sending your message Please try later</p>
          <?php }
		  elseif($_POST && $mailSent){
		   ?>
      <p><Strong>Your message been sent.Thank you "young jedi" for your response!</Strong></p>
      <?php } ?>
        <form id="feedback" method="post" action="">
            <p>
                <label for="name">Name:<?php
                if(isset($missing) && in_array('name',$missing)){ ?>
                <span class ="warning">Please enter your name</span><?php } ?>
                </label>
                <input name="name" id="name" type="text" class="formbox">
                <?php if(isset($missing)){
					echo 'value="'.htmlentities($_POST['name']).'"';
				} ?>
            </p>
            <p>
                <label for="email">Email:<?php 
				if(isset($missing) && in_array('email',$missing)){ ?>
                  <span class="warnng">please enter your email</span><?php } ?>
				</label>
                <input name="email" id="email" type="text" class="formbox">
                <?php if(isset($missing)){
                echo 'value="'.htmlentities($_POST['email']).'"';
                } ?>
            </p>
            <p>
                <label for="comments">Comments:<?php
                if(isset($missing) && in_array('comments',$missing)){?>
                <span class="warning"> please enter your comment dumb ass!</span><?php } ?>
                
                </label>
              <textarea name="comments" id="comments" cols="60" rows="8"></textarea>
            </p>
            <fieldset id="subscribe">
            <h2> Subscribe to my newsletter?</h2>
            <p>
            <input name="subscribe" type="radio" value="Yes" id="subscribe-yes"
            <?php
			$OK = isset($_POST['subscribe']) ? true : false;
			if ($OK && isset($missing) && $_POST['subscribe'] == 'Yes'){ ?>
            checked="checked"
            <?php } ?>
            />
            <label for="subscribe-yes">Yes</label>
            <input name="subscribe" type="radio" value="NO" id="subscribe-no"
            <?php
			if ($OK && isset($missing) && $_POST['subscribe'] == 'No') { ?>
            checked = "checked"
            <?php } ?>
            />
            <label for ="subscribe-no">No</label>
            <p>
            <fieldset id="interests">
            <h2>what can I help you with:</h2>
            <div>
            <p>
            <input type="checkbox" name="interests[]" value"Healthy" id="healing"
            <?php
			$OK = isset($_POST['interests']) ? true : false;
			if($OK && isset($missing) && in_array('Healthy', $_POST['interests'])){ ?>
            checked="checked"
            <?php } ?>
            />
            <label for="Weight Loss">Weight Loss</label>
            </p>
            <p>
            <input type="checkbox" name="interests[]" value="Life Coach" id="coach"
            <?php
			if($OK && isset($missing) && in_array('Life Coach',$_POST['interests'])){?>
            checked="checked"
            <?php } ?>
            />
            <label for="Life Coach">Life Coach</label>
            </p>
            </div>
            </fieldset> 
            <p><br>
                <input name="send" id="send" type="submit" value="Send Message">
            </p>
        </form>

Open in new window

0
GaryCommented:
Looks like Ray is correct, you are not assigning a default checked radio button.
I would amend you second radio button slightly
<input name="subscribe" type="radio" value="NO" id="subscribe-no"
<?php
if (($OK && isset($missing) && $_POST['subscribe'] == 'No')||$OK==false) { ?>
checked = "checked"
<?php } ?>
/>

Open in new window

0
imagekrazyAuthor Commented:
Is it also possible in the( if array statement) i have to list the other fields also could that cause my radio buttons , drop down and muti choice dropdown not to be sent?;
if(array_key_exists('send',$_POST)){
	$to = 'circleimage@gmail.com';
	$subject = 'Feedback from summer rain wellness page';
	//list expected fields
	$expected = array('name','email','comments');
	
	//setrequired fields
	$required = array('name','comments');
	

Open in new window

0
GaryCommented:
Don't think so, you are not setting a default value in your page unless they have selected Yes.
So you need to set the No to checked if they have not selected Yes so you will always get some value.
0
imagekrazyAuthor Commented:
Hi, I am still having problems receiving ,my drop down , multiple choice box and radio button
I changed what you stated  here is the code
 
<div id="maincontent">
      <h2>Contact Us </h2>
      <?php
	  if ($_POST && isset($missing) && !empty($missing)){
		  ?>
          <p class="warning">Please complete  the missing items(s) indicated.</p>
          <?php
	  }
	  elseif ($_POST && !$mailSent) {
		  ?>
          <p class="Warning">Sorry, there was problem sending your message Please try later</p>
          <?php }
		  elseif($_POST && $mailSent){
		   ?>
      <p><Strong>Your message been sent.Thank you "young jedi" for your response!</Strong></p>
      <?php } ?>
        <form id="feedback" method="post" action="">
            <p>
                <label for="name">Name:<?php
                if(isset($missing) && in_array('name',$missing)){ ?>
                <span class ="warning">Please enter your name</span><?php } ?>
                </label>
                <input name="name" id="name" type="text" class="formbox">
                <?php if(isset($missing)){
					echo 'value="'.htmlentities($_POST['name']).'"';
				} ?>
            </p>
            <p>
                <label for="email">Email:<?php 
				if(isset($missing) && in_array('email',$missing)){ ?>
                  <span class="warnng">please enter your email</span><?php } ?>
				</label>
                <input name="email" id="email" type="text" class="formbox">
                <?php if(isset($missing)){
                echo 'value="'.htmlentities($_POST['email']).'"';
                } ?>
            </p>
            <p>
                <label for="comments">Comments:<?php
                if(isset($missing) && in_array('comments',$missing)){?>
                <span class="warning"> please enter your comment dumb ass!</span><?php } ?>
                
                </label>
              <textarea name="comments" id="comments" cols="60" rows="8"></textarea>
            </p>
            <p>
            <label for="select">How did you hear about us?</label>
            <select name="howhear" id="howhear">
            <option value="No reply"
            <?php
			if(!$_POST|| $_POST['howhear'] == 'No reply'){ ?>
            selected="selected"
            <?php } ?>
            >Select one</option>
            <option value="foED"
            <?php
			if(isset($missing) && $_POST['howhear'] == 'foED') { ?>
            selected="selected"
            <?php } ?>
            >friends of Steve</option>
            ...
            </select>
            
            </p>
            <p>
            <label for = "select">This is a test drop down</label>
            <select name="Characteristics[]" size="6" multiple="mutiple" id="charcteristics">
            <option value="Dynamic"
            <?php
			$OK = isset($_POST['charateristics']) ? true : false;
			if ($OK && isset($missing) && in_array('Dynamic',$_POST['characteristics'])){?>
            selected="selected"
            <?php } ?>
            >Dynamic</option>>
            <option value="Honest"
            <?php
			if($OK && isset($missing) && in_array('Honest',$_POST['characteristics'])) {?> selected="selected"
            <?php } ?>
            >Honest</option>
            ...
            </select> 
            </p>
            <fieldset id="subscribe">
            <h2> Subscribe to my newsletter?</h2>
            <p>
            <input name="subscribe" type="radio" value="No" id="subscribe-no"
            <?php
			$OK = isset($_POST['subscribe']) ? true : false;
			if ($OK && isset($missing) && $_POST['subscribe'] == 'No'){ ?>
            checked="checked"
            <?php } ?>
            />
            <label for="subscribe-yes">Yes</label>
            <input name="subscribe" type="radio" value="NO" id="subscribe-no"
            
            
<?php
if (($OK && isset($missing) && $_POST['subscribe'] == 'No')||$OK==false) { ?>
checked = "checked"
<?php } ?>
/>
            <label for ="subscribe-no">No</label>
            <p>
            <fieldset id="interests">
            <h2>what can I help you with:</h2>
            <div>
            <p>
            <input type="checkbox" name="interests[]" value"Healthy" id="healing"
            <?php
			$OK = isset($_POST['interests']) ? true : false;
			if($OK && isset($missing) && in_array('Healthy', $_POST['interests'])){ ?>
            checked="checked"
            <?php } ?>
            />
            <label for="Weight Loss">Weight Loss</label>
            </p>
            <p>
            <input type="checkbox" name="interests[]" value="Life Coach" id="coach"
            <?php
			if($OK && isset($missing) && in_array('Life Coach',$_POST['interests'])){?>
            checked="checked"
            <?php } ?>
            />
            <label for="Life Coach">Life Coach</label>
            </p>
            </div>
            </fieldset> 
            <p><br>
                <input name="send" id="send" type="submit" value="Send Message">
            </p>
        </form>
      
</div>

Open in new window

0
Kim WalkerWeb Programmer/TechnicianCommented:
You should be able to see whether or not one of the radio buttons is selected before you submit the form. You've only mentioned that they are not being sent. Are they not being selected either?
0
imagekrazyAuthor Commented:
yes ,sorry about that its not being selected.
0
Kim WalkerWeb Programmer/TechnicianCommented:
Do people have to submit another form to get to this form? The only way there would be $_POST data is if the previous page submits a form using method="post".

As Ray_Paseur suggested, please var_dump your values to see what values you're dealing with. Replace lines 1-5 above with:
<div id="maincontent">
      <h2>Contact Us </h2>
      <?php
	  var_dump($_POST);
	  var_dump($missing);
	  if ($_POST && isset($missing) && !empty($missing)){
		  ?>

Open in new window

I've inserted two lines of code here. Please report back to us what is inserted into your page after the "Contact Us" line.
0
imagekrazyAuthor Commented:
it stated:

array(0) { }
Notice: Undefined variable: missing in /home/content/64/11583764/html/summer/test2/contact.php on line 111
NULL
0
Kim WalkerWeb Programmer/TechnicianCommented:
You didn't answer my first question:  
Do people have to submit another form to get to this form? The only way there would be $_POST data is if the previous page submits a form using method="post".
0
imagekrazyAuthor Commented:
Sorry about that , no this is the only form.
0
Kim WalkerWeb Programmer/TechnicianCommented:
So, all of your logic -- the if statements and conditional operations based on $_POST data and the $missing variable -- are for AFTER the form is submitted. The form tag suggests that the form is submitted to itself (action = ""). So nothing SHOULD be selected when the form is displayed the first time. Right?

If so, then the buttons and checkboxes must be selected manually, the text fields must be filled in and then the "Send Message" button clicked. Is that when the radio button selections are being omitted. The title of this question is "Email form is not sendding my data from my radio button groups." There doesn't appear to be anything posted here to suggest that this is an "email" form. What do you mean by that? Help us to understand what you need help with.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
I have to sign off on this one -- there are just too many fundamental misunderstandings, and I don't think a back-and-forth forum is the right place to try to learn all of the moving parts.  You should throw away all of this confused code and start over.  That will be faster than trying to fix what I've seen here.  Don't feel bad about it; it's called refactoring, and professionals do it all the time.  So I'll leave you with some links that can help you get started.

Two required readings from the PHP.net man pages.
http://php.net/tut.php
http://php.net/manual/en/tutorial.forms.php

An article that tells how Client/Server protocols work (request / response).
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

An article that can help guide you as you learn about internet applications and PHP.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

A form-to-email script that works (just plug in your values) and may be able to give you a working foundation.  Then you can add the rest of your form values and capture them in the action script.

<?php // RAY_form_to_email.php
error_reporting(E_ALL);


// SEND MAIL FROM A FORM


// REQUIRED VALUES ARE PREPOPULATED - CHANGE THESE FOR YOUR WORK
$from = 'NoReply@Your.org';
$subj = 'Contact Form';

// THIS IS AN ARRAY OF RECIPIENTS - CHANGE THESE FOR YOUR WORK
$to[] = 'You@Your.org';
$to[] = 'Her@Your.org';
$to[] = 'Him@Your.org';
$to[] = 'Ray.Paseur@Gmail.com';


// IF THE DATA HAS BEEN POSTED (AT LEAST SOMETHING IN THE EMAIL INPUT CONTROL)
if (!empty($_POST['e']))
{
    // CLEAN UP THE POTENTIALLY BAD AND DANGEROUS DATA
    $safe_mail = clean_string($_POST['e']);
    $safe_name = clean_string($_POST['n']);
    $safe_fone = clean_string($_POST['t']);
    $save_idea = clean_string($_POST['i']);

    // CONSTRUCT THE MESSAGE THROUGH STRING CONCATENATION
    $content    = NULL;
    $content   .= "You have a New Query From $safe_name" . PHP_EOL . PHP_EOL;
    $content   .= "Tel No: $safe_fone" . PHP_EOL;
    $content   .= "Email: $safe_mail" . PHP_EOL;

    // SEND MAIL TO EACH RECIPIENT
    foreach ($to as $recipient)
    {
        if (!mail( $recipient, $subj, $content, "From: $from\r\n"))
        {
            echo PHP_EOL . "<br/>MAIL FAILED FOR $recipient";
        }
        else
        {
            echo PHP_EOL . "<br/>MAIL WORKED FOR $recipient";
        }
    }

    // PRODUCE THE THANK-YOU PAGE
    echo '<p>THANK YOU</p>' . PHP_EOL;
    die('TASK COMPLETE');
}


// A FORM TO TAKE CLIENT INPUT FOR THIS SCRIPT
$form = <<<ENDFORM
<form method="post">
Please enter your contact information
<br/>Email: <input name="e" />
<br/>Phone: <input name="t" />
<br/>Name:  <input name="n" />
<br/>Ideas? <textarea name="i"></textarea>
<br/><input type="submit" />
</form>
ENDFORM;

echo $form;


// A FUNCTION TO CLEAN UP THE DATA - AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    // IF MAGIC QUOTES IS ON, WE NEED TO REMOVE SLASHES
    $str = stripslashes($str);

    // REMOVE EXCESS WHITESPACE
    $rgx
    = '#'                // REGEX DELIMITER
    . '\s'               // MATCH THE WHITESPACE CHARACTER(S)
    . '\s+'              // MORE THAN ONE CONTIGUOUS INSTANCE OF WHITESPACE
    . '#'                // REGEX DELIMITER
    ;
    $str = preg_replace($rgx, ' ', $str);

    // REMOVE UNWANTED CHARACTERS
    $rgx
    = '#'                // REGEX DELIMITER
    . '['                // START OF A CHARACTER CLASS
    . '^'                // NEGATION - MATCH NONE OF THE CHARACTERS IN THIS CLASS
    . 'A-Z0-9'           // KEEP LETTERS AND NUMBERS
    . '"'                // KEEP DOUBLE QUOTES
    . "'"                // KEEP SINGLE QUOTES
    . '@&+:?_.,/\-'      // KEEP SOME SPECIAL CHARACTERS (ESCAPED HYPHEN)
    . ' '                // KEEP BLANKS
    . ']'                // END OF THE CHARACTER CLASS
    . '#'                // REGEX DELIMITER
    . 'i'                // CASE-INSENSITIVE
    ;
    $str = preg_replace($rgx, NULL, $str);

    // REMOVE EXCESSIVE INPUT
    $str = substr($str, 0, 255);

    return trim($str);
}

Open in new window

0
imagekrazyAuthor Commented:
Hi, I made a email form from the book I was reading, it stated that I can have a radio button, drop down option, and mutiple-choice in my email form, so I followed the direction ,got some errors, but with the help from teh people fromexpert exchange it got resolved. so in this email form everything almost works the name field works, the message field works, and the email field works, but not the data from the above that i explained.


 an here is the test link to the form
0
Ray PaseurCommented:
Computer programming is an activity that requires almost superhuman precision and attention to detail, so when I see something like a copyright notice with this...

© 20010–13Circle Image Inc.

... I figure that other things could be wrong, too.  Fortunately for us humans, we do not have to guess about the accuracy of many things.  For example, we can check the markup of the HTML document.  This is a "first step" in the direction of getting your HTML forms and PHP scripts to work together.
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.summerrainwellness.com%2Ftest2%2Fcontact.php&charset=%28detect+automatically%29&doctype=Inline&group=0
0
imagekrazyAuthor Commented:
Hi, Ray thanks for the input, I greatly appreciate your help, I took your advice and started over,
and about the copyright , that is my company, circle image productions, I am an independent film maker /producer,  I also have  other companies:)
so if I am asking help for for other projects and you see that copyright notice that is me:)
Oh like I stated before, I started over and when  I submit that,I am going have little issues here and there, so any help will be gratefully accepted!
0
imagekrazyAuthor Commented:
Thank you everyone for your help.
0
Ray PaseurCommented:
The point about the copyright is that the date does not make sense.  Maybe something like 2010-13 would make sense.

Here is a version of the form that will validate and also show the values coming through to the action script.  HTH, and best of luck with it, ~Ray

http://www.laprbass.com/RAY_temp_imagekrazy.php

<?php // RAY_temp_imagekrazy.php
error_reporting(E_ALL);
if (!empty($_POST))
{
    echo '<pre>';
    var_dump($_POST);
    die();
}
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<base href="http://www.summerrainwellness.com/test2/" />

<title>summer rain wellness</title>

<link href="css/contactStyle.css" rel="stylesheet" type="text/css">
</head>
<body>

<div id="header">
    <h1>Summer Rain Wellness</h1>
</div>
<div id="wrapper">
<ul id="nav">
  <li><a href="index.php" >Home</a></li>
  <li><a href="blog.php" >Blog</a></li>
  <li><a href="gallery.php" >Gallery</a></li>
  <li><a href="contact.php" id="here">Contact</a></li>
</ul>

    <div id="maincontent">
      <h2>Contact Us </h2>
              <form id="feedback" method="post">
            <p>
                <label for="name">Name:                </label>
                <input name="name" id="name" type="text" class="formbox">
                            </p>
            <p>
                <label for="email">Email:				</label>
                <input name="email" id="email" type="text" class="formbox">
                            </p>
            <p>
                <label for="comments">Comments:
                </label>
              <textarea name="comments" id="comments" cols="60" rows="8"></textarea>
            </p>
            <p>
            <label for="howhear">How did you hear about us?</label>
            <select name="howhear" id="howhear">
            <option value="No reply" selected="selected">Select one</option>
            <option value="foED">friends of Steve</option>
            </select>

            </p>
            <p>
            <label for="charcteristics">This is a test drop down</label>
            <select name="Characteristics[]" size="6" multiple id="charcteristics">
            <option value="Dynamic">Dynamic</option>
            <option value="Honest">Honest</option>
            </select>
            </p>
            <fieldset id="subscribe">
            <h2> Subscribe to my newsletter?</h2>
            <p>
            <input name="subscribe" type="radio" value="YES" id="subscribe-yes"/>
            <label for="subscribe-yes">Yes</label>
            <input name="subscribe" type="radio" value="NO"  id="subscribe-no" checked />
            <label for ="subscribe-no">No</label>
            <p>
            <fieldset id="interests">
            <h2>what can I help you with:</h2>
            <div>
            <p>
            <input type="checkbox" name="interests[]" value="Healthy" id="healing" />
            <label for="healing">Weight Loss</label>
            </p>
            <p>
            <input type="checkbox" name="interests[]" value="Life Coach" id="coach" />
            <label for="coach">Life Coach</label>
            </p>
            </div>
            </fieldset>
            </fieldset>
            <p><br>
                <input name="send" id="send" type="submit" value="Send Message" />
            </p>
        </form>

</div>
    <div id="footer">
<p>&copy;
 2010&#8211;13 Circle Image Inc.
</div></div>
</body>
</html>

Open in new window

0
imagekrazyAuthor Commented:
Thanks again Ray,

and i finally got the email form to work with other cool stuff,

check it out when you have time:

My Working Email Form
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.