PHP联系表单不显示电子邮件中的输入字段数据

时间:2017-01-06 15:01:29

标签: php html forms

我是PHP的新手。所以,我创建了一个PHP表单,一切正常,但是当发送电子邮件时,(名称,电子邮件和消息)内容不会显示。电子邮件中显示的内容是:姓名:电子邮件:消息:非常感谢任何帮助。

电子邮件屏幕截图 [这是电子邮件中的内容] [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\">";
}
?>

0 个答案:

没有答案