0

I'm new to PHP. So, I created a PHP form and everything works but when the email is sent, the (Name, Email and Message) content does not display. What does display in the email are the words: Name: Email: Message:. Any help is greatly appreciated.

Email Screenshot [This is what comes through in the email][1]

HTML:

 <form data-name="Email Form" id="email-form" name="email-form" method="post" action="contactengine.php?" enctype="text/plain">
        <div class="row w-row">
          <div class="column w-clearfix w-col w-col-6">
            <label class="field-name" for="name">Name</label>
            <input class="input-box w-input" data-name="Name" id="name" maxlength="256" name="name" placeholder="Your name" required="required" type="text">
          </div>
          <div class="column w-clearfix w-col w-col-6">
            <label class="field-name" for="Email">Email</label>
            <input class="input-box w-input" data-name="Email" id="Email" maxlength="256" name="Email" placeholder="Your email" required="required" type="email">
          </div>
        </div>
        <div class="w-clearfix">
          <label class="field-name" for="field">Message</label>
          <textarea class="big-form input-box message w-input" id="field" maxlength="5000" name="field" placeholder="Your message" required></textarea>
        </div>
        <input class="button top-border w-button" data-wait="Please wait..." value="Submit" type="submit">
      </form>

PHP

<?php

$EmailFrom = "craig@craigrobydesigns.com";
$EmailTo = "craig@craigrobydesigns.com";
$Subject = "Contact Me";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
} 
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
  • This is both a duplicate of http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index and http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail - You have errors and error reporting would have helped you. http://php.net/manual/en/function.error-reporting.php and this is an issue `enctype="text/plain"` – Funk Forty Niner Jan 06 '17 at 15:09
  • you could try this: https://css-tricks.com/html-forms-in-html-emails/ – scrat.squirrel Jan 06 '17 at 15:11
  • $Name = Trim(stripslashes($_POST['name'])); So Name should be name in lowercase since that is the id of your field. Not sure though. –  Jan 06 '17 at 15:11

0 Answers0