Php form failing

2020-05-01 07:24发布

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.

This is the code I have,

        <?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.

1条回答
闹够了就滚
2楼-- · 2020-05-01 07:43

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" />

etc, etc...

查看更多
登录 后发表回答