title: I am unable to send a message using .php
body: <p>I am unable to send a message using .php.</p>
  
  <p>Strangely, I have tested and been able to send messages in the past, but for some reason I now get the message '* The Message field must contain only letters, digits, spaces and basic punctuation ( ' - , . ), has a limit of 1000 characters &amp; should not be left empty. '.</p>
  
  <p>I'm aware that it's a message gerneaed due to  conflict in the message form and the .php, but don't have the skill to rectify it.</p>
  
  <p>I built a website a while back using the same contact &amp; .php forms and that too has the same problem.</p>
  
  <p>Please advise:</p>
  
  <pre><code>&lt;?php
  
  
  $your_email = "mailto@host.com"; // email address to which the form data will be sent
  $subject = "Subject Here"; // subject of the email that is sent
  $thanks_page = "/thankyou/"; // path to the thank you page following successful form submission
  $contact_page = "http://test.com/contact/index.html"; // path to the HTML contact page where the form appears
  
  
  
  if (!isset($_POST['submit'])) {
      header( "Location: $contact_page" );
    }
  
  if (isset($_POST["submit"])) {
      $nam = $_POST["name"];
      $ema = trim($_POST["email"]);
      $mes = $_POST["message"];
      $spa = $_POST["spam"];
  
      if (get_magic_quotes_gpc()) { 
      $nam = stripslashes($nam);
      $ema = stripslashes($ema);
      $mes = stripslashes($mes);
      }
  
  $error_msg=array(); 
  
  if (empty($nam) || !preg_match("~^[a-z\-'\s]{1,60}$~i", $nam)) { 
  $error_msg[] = "&lt;br/&gt;* The name field must contain only letters, spaces, dashes ( - ) and single quotes ( ' ).\n&lt;br /&gt;\n&lt;br /&gt;";
  }
  
  if (empty($ema) || !filter_var($ema, FILTER_VALIDATE_EMAIL)) {
      $error_msg[] = "&lt;br/&gt;* Your email must have a valid format, such as name@mailhost.com\n&lt;br /&gt;\n&lt;br /&gt;";
  }
  
  $limit = 1000;
  
  if (empty($mes) || !preg_match("/^[0-9A-Za-z\/-\s'\(\)!\?\.,]+$/", $mes) || (strlen($mes) &gt; $limit)) { 
  $error_msg[] = "&lt;br/&gt;* The Message field must contain only letters, digits, spaces and basic punctuation (&amp;nbsp;'&amp;nbsp;-&amp;nbsp;,&amp;nbsp;.&amp;nbsp;), has a limit of 1000 characters &amp;amp; should not be left empty.\n&lt;br /&gt;\n&lt;br /&gt;";
  }
  
  if (!empty($spa) &amp;&amp; !($spa == "4" || $spa == "four")) {
      echo "* You failed the spam test! Please go back and try again.\n&lt;br /&gt;\n&lt;br /&gt;";
      exit ();
  }
  
  if ($error_msg) {
  echo '&lt;!--CONTACT---&gt;
  &lt;!DOCTYPE html&gt;
  &lt;!--[if lt IE 7]&gt;&lt;html lang="en-US" class="no-js lt-ie9 lt-ie8 lt-ie7"&gt;&lt;![endif]--&gt;
  &lt;!--[if IE 7]&gt;&lt;html lang="en-US" class="no-js lt-ie9 lt-ie8"&gt;&lt;![endif]--&gt;
  &lt;!--[if IE 8]&gt;&lt;html lang="en-US" class="no-js lt-ie9"&gt;&lt;![endif]--&gt;
  &lt;!--[if gt IE 8]&gt;&lt;!--&gt;&lt;html lang="en-US" class="js"&gt;&lt;!--&lt;![endif]--&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;';
  exit();
  } 
  
  $email_body = 
      "Name of Sender: $nam\n\n" .
      "Email: $ema\n\n" .
      "Message:\n\n" .
      "$mes" ; 
  
  
  if (isset($_REQUEST['message']) &amp;&amp; !$error_msg) {
  mail ($your_email, $subject, $email_body, "From: $nam &lt;$ema&gt;" . "\r\n" . "Reply-To: $nam &lt;$ema&gt;");
  header ("Location: $thanks_page");
  exit();
  }  
  }
  </code></pre>
  
  <p>An example of the contact form working incorrectly can be tried here - <a href="http://mickscaricatures.co.uk/contact.html" rel="nofollow">http://mickscaricatures.co.uk/contact.html</a></p>
  
  <p>Is there any further information I can supply to help resolve this situation?</p>