Email form is not sending the information

Hi,
 there is no syntax error,
I am receiving the email form , but no information that is in the fields is going thru, can't figure that out.

<?php 
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');
	//create empty array for missing fields
	$missing = array();
	
	//process the $_POST variables
	foreach($_POST as $key => $value) {
		//assign to temporary variable bd strip whitespace if not an array
		$temp = is_array($value) ? $value : trim($value);
		// if empty and required add to $missing array
		if (empty($temp) && in_array($key,$required)){
			array_push($missing,$key);
		}
		//otherwise, assign to a variable of the same name as $key
		elseif (in_array($key,$expected)){
			${key}= $temp;
		}
	}

	//go head only if all required fileds OK
	if(empty($missing)){
	//build the message
	$message = "Name: $name\n\n";
	$message .= "Email: $email\n\n";
	$message .= "Comments: $comments";
	
	//limit line length to 70 characters
	$message = wordwrap($message,70);
	
	//sent it
	$mailSent = mail($to, $subject, $message);
	if ($mailSent){
		//$missing is no longer needed if the email is sent so unset it 
		unset($missing);
	}
	}
}
?>
<!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">
            </p>

Open in new window


and here is also the form:

<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">
            </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>
                <input name="send" id="send" type="submit" value="Send message">
            </p>
        </form>

Open in new window

imagekrazyAsked:
Who is Participating?
 
GaryCommented:
${key}= $temp;

should be

${$key}= $temp;

You may want to add a FROM parameter.
0
 
imagekrazyAuthor Commented:
Wow I can't believe something as simple of leaving something out cause  a major  headache.

Thank you!
 Just want to know how do i catch errors like that if the editor tells me nothing is wrong?
0
 
GaryCommented:
Add the following at the top of your code

error_reporting(E_ALL);
0
 
imagekrazyAuthor Commented:
within the php tag or above it?
0
 
GaryCommented:
Just after your first opening php tag
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.