PHP 以电子邮件形式返回空白字段


PHP returns blank fields in email form

我的收件箱中仅收到表单字段中部分的空白字段返回

这样:

From: whatevername
Email: fgsdfg@fakeysite.com 
Message: 
phone:

这是我的代码,它可能真的很愚蠢,但它困扰着我,所以我们开始了。

.HTML

        <div class="row-item col-1_4">
<h3>Contact Form</h3>
<h4>Please fill out the form to get your free CD Replacement Kit</h4>
<!-- Success Message -->
<div class="form-message"></div>
<!-- Form -->
<form class="b-form b-contact-form" action="blast.php">
   <div class="input-wrap m-full-width">
      <i class="icon-user"></i>
      Name
      <input class="field-name" type="text" placeholder="Name (required)">
   </div>
   <div class="input-wrap m-full-width">
      <i class="icon-phone"></i>
      Phone
      <input class="field-phone" type="text" placeholder="Phone">
   </div>
   <div class="input-wrap m-full-width">
      <i class="icon-envelope"></i>
      Email
      <input class="field-email" type="text" placeholder="E-mail (required)">
   </div>
   <div class="input-wrap m-full-width">
      <i class="icon-pencil"></i>
      Message
      <input class="field-comments" type="text"  placeholder="Message">
   </div>
   <input class="btn-submit btn colored" type="submit" value="Send">
</form>

.PHP

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$formcontent=" From: $name 'n Email: $email 'n Phone: $phone 'n Message: $message";
$recipient = "csmith@legacybrokerage.com";
$subject = "UNLIMITED ANNUITY LEADS CD BLAST";
$mailheader = "From: $email 'r'n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";

试试这个,定义输入字段的name= 'something'

  <input class="field-name" type="text" placeholder="Name (required)" name="name">
  <input class="field-phone" type="text" placeholder="Phone" name="phone">
  <input class="field-email" type="text" placeholder="E-mail (required)" name="email">

您的输入剂量不是name属性!

<input class="field-name" type="text" placeholder="Name (required)">

正确:

<input name="from" class="field-name" type="text" placeholder="Name (required)">