title: code error in validated php contact form to mail
body: <p>i coded a contact us page and validate it what i want is when user clicks the send button the info should validate first then sent an email to given hardcoded email address i'm facing an issue don't know why my coding is not working, validation is fine but when i click on submit button it doesn't show any success message about the email and not sending email. do help please here is my code:</p>
  
  <pre><code>&lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;
  
                          &lt;label&gt;Your Name: * &lt;/label&gt;
                          &lt;span style="color:#F00;" class="error"&gt;&lt;?php echo $nameErr;?&gt;&lt;/span&gt;
                          &lt;input type="text" name="name" placeholder="Noman" width="100px;"&gt;
  
                          &lt;label&gt;Email Id: * &lt;/label&gt;
                          &lt;span style="color:#F00;" class="error"&gt;&lt;?php echo $emailErr;?&gt;&lt;/span&gt;
                          &lt;input type="text" name="email" placeholder="yourname@gmail.com"&gt;
  
                          &lt;label&gt;Contact Number (Optional): &lt;/label&gt;
                          &lt;span style="color:#F00;" class="error"&gt;&lt;?php echo $contactErr;?&gt;&lt;/span&gt;
                          &lt;input type="text" name="contact" placeholder="0312-1234567"&gt;
  
                          &lt;label&gt;  Website URL (Optional):&lt;/label&gt;
                          &lt;span style="color:#F00;" class="error"&gt;&lt;?php echo $websiteErr;?&gt;&lt;/span&gt;
                          &lt;input type="text" name="website" placeholder="www.yoursite.com"&gt;
  
                          &lt;label&gt;  Message: * &lt;/label&gt;
                          &lt;span style="color:#F00;" class="error"&gt;&lt;?php echo $messageErr;?&gt;&lt;/span&gt;
                          &lt;textarea name="message" rows="10" cols="10" placeholder="Message"&gt;&lt;/textarea&gt;
  
                          &lt;input type="submit" name="submit" value="Submit" id="submit"&gt;      
                      &lt;/form&gt; 
  </code></pre>
  
  <p>and here is my php code </p>
  
  <pre><code>&lt;?php
                           function test_input($data) {
                            $data = trim($data);
                            $data = stripslashes($data);
                            $data = htmlspecialchars($data);
                            return $data;
                          }
                           $name= $email= $contact= $website= $message="";                            
                          $nameErr = $emailErr = $contactErr = $websiteErr = $messageErr = "";
  
                            if ($_SERVER["REQUEST_METHOD"] == "POST")
                            {                           
                            if (empty($_POST["name"])) {
                              $nameErr = "Name is required";
                            } else {
                              $name = test_input($_POST["name"]);
                              if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
                                $nameErr = "Only letters and white space allowed"; 
                              }
                            }
  
                            if (empty($_POST["email"])) {
                              $emailErr = "Email is required";
                            } else {
                              $email = test_input($_POST["email"]);
                              if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                                    $emailErr = "Invalid email format"; 
                                  }
                            }
  
                            if (empty($_POST["contact"])) {
                              $contact = "";
                            } else {
                              $contact = test_input($_POST["contact"]);
                            if(!is_numeric($contact)){
                                $contactErr="Please enter valid mobile number";
                              }
                              else if(strlen($contact) != 11) {
                              $contactErr="Please enter valid mobile number";
                              }
                            }
  
                            if (empty($_POST["website"])) {
                              $website = "";
                            } else {
                              $website = test_input($_POST["website"]);
                               if (!preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&amp;@#\/%?=~_|!:,.;]*[-a-z0-9+&amp;@#\/%=~_|]/i",$website)) {
                                    $websiteErr = "Invalid URL"; 
                                  }
                            }
  
                            if (empty($_POST["message"])) {
                              $messageErr = "Message is required";
                            } else {
                              $message = test_input($_POST["message"]);
                            }
                          }
  
                          $from = $_POST["email"]; // sender
                          $subject = $_POST["name"];
                          $message = $_POST["message"];
                          // message lines should not exceed 70 characters (PHP rule), so wrap it
                          $message = wordwrap($message, 200);
                          // send mail
                          mail("abc@gmail.com",$subject,$message,"From: $email\n");
                          echo "Thank you for sending us feedback";
  
  
                          ?&gt; 
  </code></pre>