0

I don't understand what's wrong but my contact form is running the "mail" script, but without any of the POST data. Can anyone tell me why it isn't working?

index.php:

<form id="newsletter-form" class="newsletter_form" action="php/order.php" method="post">
<input id="email_newsletter" required type="text" name="or_name" placeholder="Name*"> 
<input id="email_newsletter" type="text" name="or_company" placeholder="Company Name">
<input id="email_newsletter" required type="email" name="or_email" placeholder="Email*">
<input id="email_newsletter" type="tel" name="or_tel" placeholder="Phone">
<select id="email_newsletter" required name="or_package">
    <option value="" selected disabled>Select Package*</option>
    <option value="Starter">Starter - 1 Page Site £49</option>
    <option value="Business">Business - 3 Page Site £99</option>
    <option value="Premier">Premier - 6 Page Site £179</option>
</select>
<textarea id="email_newsletter" required class="or_tarea" name="or_details" placeholder="Project Details*"></textarea>
<input type="submit" value="SUBMIT!" id="submit-button-newsletter">
</form>

order.php:

<?php
$field_name = $_POST['or_name'];
$field_company = $_POST['or_company'];
$field_email = $_POST['or_email'];
$field_tel = $_POST['or_tel'];
$field_package = $_POST['or_package'];
$field_details = $_POST['or_details'];

$mail_to = 'my@email.com'; //Change to your email
$subject = 'Enquiry from '.$field_name.' ('.$field_company.')'; //Change to your subject

$body_message = 'From: '.$field_name."\n";
$body_message .= 'Company: '.$field_company."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Phone: '.$field_tel."\n";
$body_message .= 'Package: '.$field_package."\n";
$body_message .= 'Details: '.$field_details;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

?>

Of Course the email is directed to my inbox. When I fill out the form and press send, I receive this blank email:

Subject;
Enquiry from  ()
Message;
From: 
Company: 
E-mail: 
Phone: 
Package: 
Details:
jeroen
  • 91,079
  • 21
  • 114
  • 132
Michael Ruta
  • 345
  • 3
  • 7
  • 13
  • For some reason the isn't showing on this StackOverflow question, but when I go to edit, it's there. Just a heads up for people that think that's related to the problem - it's not. – Michael Ruta Jul 19 '15 at 11:32
  • Probably not related to your problem, but you have a mail header injection problem (your form processor could be used to send spam) and the ID attributes in your html have to be unique. – jeroen Jul 19 '15 at 11:46
  • I copied your code into PhpFiddle, and it seemed to work for me: http://phpfiddle.org/lite/code/2fxm-pj1u – cyberbit Jul 19 '15 at 13:42

3 Answers3

0

Just as a first step, can you echo out the POST variables into the script to make sure they are actually being set?

echo $field_name = $_POST['or_name'];
0

Check the values of all of the POST variables that are being passed.

echo print_r($_POST,true);

Check your PHP error log to see if there are any warnings/notices.

Unrelated: Are you sanitizing the user input before processing it?

Aetiranos
  • 329
  • 1
  • 6
0

So it turns out despite the HTML and PHP needing cleaning up, they were not the problem at all. It was a third party script that had been modified and it turns out there was an attached JS file where that was filtering the POST info. I modified that to include the new form inputs and it works fine :)

Michael Ruta
  • 345
  • 3
  • 7
  • 13