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

时间:2013-10-07 21:21:33

标签: php html forms

我的收件箱中只在表单字段的一部分上显示空白字段

像这样:

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!";

2 个答案:

答案 0 :(得分:3)

试试这个,将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">

答案 1 :(得分:2)

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

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

正确:

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