im having issues with my script not sending an email, the return error message is: Email address not valid! This happens when ever I enter my email address into the text field. I have a feeling that it is the (preg_match) method that is creating the issue, but after looking online I dont really understand the content of the method. Hope you guys can help, thanks.
SOURCE CODE:
  <?php
  /*Select email recipient*/
  $myemail = "info@shadowempires.url.ph";
  /*Check all form inputs using check input function*/
  $name = check_input($_POST['name'], "Please enter your name");
  $email = check_input($_POST['email'], "Please enter your email address.");
  $comment = check_input($_POST['comment'], "Please write a message.");
  /*If email is not valid show error message*/
  if (!preg_match("/(\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)){
      show_error("Email address not valid!");
  }
  /*Lets prepare the message for the email*/
  $message = "Customer Question!
  Contact form has been submitted by:
  Name: $name
  Email: $email
  Comments: $comment
  End of message";
  /*Send the message using mail() function*/
  mail($myemail, $message);
  /*Redirect visitor to the thank you page*/
  header('Location: thankyou.htm');
  exit();
  /*Functions we used*/
  function check_input($data, $problem=''){
      $data = trim($data);
      $data = stripslashes($data);
      $data = htmlspecialchars($data);
      if ($problem && strlen($data) == 0){
          show_error($problem);
      }
      return $data;
  }
  function show_error($myError){
  ?>
      <html>
      <body>
      <b>Please correct the following error:</b><br />
      <?php echo $myError; ?>
      </body>
      </html>
  <?php exit();
  }
  ?>
 
     
     
    