0

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 email 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 = '[email protected]'; 
      $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.

4
  • 1
    Try using print_r($_POST) to see exactly which values are being sent. Commented Jun 25, 2013 at 16:42
  • Also, make sure errors are turned on in php.ini, check error logs to see if theres anything there, and/or let us know what (if any) errors you received. Commented Jun 25, 2013 at 16:42
  • Your code is open to mail header injection: never trust user content. And please remove that email address to prevent harvesting. Commented Jun 25, 2013 at 16:42
  • 2
    None of your inputs have a name attribute. Commented Jun 25, 2013 at 16:44

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Finally the 'name' was the issue, thank you very much, is the first time I dare to post, and I wasn't expecting that much help, thank you :) ! I will definitely be around more.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.