PHP表格失败 [英] Php form failing

查看:51
本文介绍了PHP表格失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里阅读了很多主题,其中一些主题也有同样的问题,我只是没有巧合发现我的问题所在.我对php很陌生.

I have read a lot of threads here, and some of them had my same issue, I just didn´t happen to find what is wrong with mine. I'm quite new to php.

我正尝试将表单及其详细信息发送到电子邮件地址,到目前为止,电子邮件仍未发送.

I'm trying to send a form to an e-mail address with the details of it, and so far, the e-mail doesn't get sent.

这是我的代码,

        <?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 
            }; 
          ?>

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

I have changed all the directions to send it, but still, I'm missing something, just don't know what.

推荐答案

您的表单中没有名称属性.因此,为每个表单字段放置适当的名称属性.例如:

You don't have name atributte in your form. So, put appropriate name attribute for each form field. Eg:

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

等,等等...

这篇关于PHP表格失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆