Php表单失败

时间:2013-06-25 16:39:56

标签: php forms failing-tests

我在这里读了很多帖子,其中一些人有同样的问题,我碰巧没有发现我的错。我对php很新。

我正在尝试将表单发送到包含详细信息的电子邮件地址,到目前为止,电子邮件仍未发送。

这是我的代码,

        <?php 
          if ($_POST["email"]<>'') { 
              $ToEmail = 'vanessa@warroominc.com'; 
              $EmailSubject = 'Video Production Contact Form'; 
              $mailheader = "From: ".$_POST["email"]."\r\n"; 
              $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
              $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
              $MESSAGE_BODY = "Name: ".$_POST["name"].""; 
              $MESSAGE_BODY .= "Email: ".$_POST["email"].""; 
              $MESSAGE_BODY .= "Company: ".$_POST["company"]."";
              $MESSAGE_BODY .= "Telephone: ".$_POST["phone"]."";  
              $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; 
              mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
          ?> 
          <p>Your message was sent</p>

          <?php 
            } else { 
          ?> 

        <form class="login" method="post" action="index.php">
        <div class="fields">
          <ul>
              <li>
                <label class="form_name" for="name">Name</label>
                <input class="field_form"id="name" type="text" />
              </li>
              <li>
                <label class="form_name" for="company">Company</label>
                <input class="field_form"id="company" type="text" />
              </li>
              <li>
                <label class="form_name" for="email">Email</label>
                <input class="field_form" id="email" type="email" />
              </li>
              <li>
                <label class="form_name"for="phone">Phone</label>
                <input class="field_form" id="phone" type="text" />
              </li>

             <li> 
              <button class="buttonred" type="submit" value="Submit"> Download the PDF </button>
            </li>
            </ul>
          </div>       

        </form>
          <?php 
            }; 
          ?>

我已经改变了发送它的所有方向,但是,我仍然缺少一些东西,只是不知道是什么。

1 个答案:

答案 0 :(得分:4)

您的表单中没有name属性。因此,为每个表单字段添加适当的名称属性。例如:

 <label class="form_name" for="email">Email</label>
                <input class="field_form" name="email" id="email" type="email" />

等等...