PHP mail form not working
<p>I am making a feedback form for my website using php, I thought that it was working, but then it took an arrow to the code.</p>

<p>Anyways, the form has 4 fields: "name", "email", "subject", and "message".</p>

<p>I get the "Message failed" alert if all four fields have content.</p>

<p>Seeing as that is the case, I tested with content in 3 of the 4 fields, which gives me 4 combinations:</p>

<pre><code>combo 1 - "name", "email", "subject"
combo 2 - "name", "email", "message"
combo 3 - "name", "subject", "message"
combo 4 - "email", "subject", "message"
</code></pre>

<p>The results were as follows:</p>

<pre><code>combo 1 - "Thank you for your message."
combo 2 - "Thank you for your message."
combo 3 - "Message failed."
combo 4 - "Thank you for your message."
</code></pre>

<p>Here is the html code I am using:</p>

<pre><code>&lt;form action="contact.php" method="post"&gt;
  &lt;input type="hidden" name="page" value="contact" /&gt;
  &lt;input type="hidden" name="req" value="submit" /&gt;
  Your Name: &lt;input type="text" name="name" /&gt;
  &lt;br/&gt;
  Your Email: &lt;input type="text" name="email" /&gt;
  &lt;br/&gt;
  Subject: &lt;input type="text" name="subject" size="69" /&gt;
  &lt;br/&gt;
  Message:
  &lt;br/&gt;
  &lt;textarea cols="63" rows="8" name="message"&gt;&lt;/textarea&gt;
  &lt;/br&gt;
  &lt;input type="submit" value="Send" /&gt;
  &lt;input type="reset" value="Clear" /&gt;
&lt;/form&gt;
</code></pre>

<p>And here is contact.php:</p>

<pre><code>&lt;?php
  $field_name = $_POST['name'];
  $field_email = $_POST['email'];
  $field_subject = $_POST['subject'];
  $field_message = $_POST['message'];

  $mail_to = 'email@my_website.com';
  $subject = 'Message from a site visitor '.$field_name;

  $body_message = 'From: '.$field_name."\n";
  $body_message .= 'E-mail: '.$field_email."\n";
  $body_message .= 'Subject: '.$field_subject."\n";
  $body_message .= 'Message: '."\n";
  $body_message .= $field_message;

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

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

  if ($mail_status) { ?&gt;
&lt;script language="javascript" type="text/javascript"&gt;
  alert('Thank you for your message.');
  window.location = './contact.html';
&lt;/script&gt;
&lt;?php
  }
  else { ?&gt;
&lt;script language="javascript" type="text/javascript"&gt;
alert('Message failed.');
window.location = './contact.html';
&lt;/script&gt;
&lt;?php
  }
?&gt;
</code></pre>

<p>Is there anything wrong with the code? I don't understand why it is doing this.</p>

<p>I hope I have been clear. Thanks in advanced for any help, it will be greatly appreciated.</p>
