Dear Sir/Madam,

i was working on a prayer request form for our church website, but when testing the form online i get the error above. The following are my code for php and form fields.

<?php
if (isset($_REQUEST['submitted'])) {
  $errors = array();
  // Check for a proper First name
  if (!empty($_REQUEST['firstname'])) {
  $firstname = $_REQUEST['firstname'];
  $pattern = "/^[a-zA-Z0-9\_]{2,20}/";
  if (preg_match($pattern,$firstname)){ $firstname = $_REQUEST['firstname'];}
  else{ $errors[] = 'Your Name can only contain _, 1-9, A-Z or a-z 2-20 long.';}
  } else {$errors[] = 'You forgot to enter your First Name.';}
 
  if (!empty($_REQUEST['lastname'])) {
  $lastname = $_REQUEST['lastname'];
  $pattern = "/^[a-zA-Z0-9\_]{2,20}/";
  if (preg_match($pattern,$lastname)){ $lastname = $_REQUEST['lastname'];}
  else{ $errors[] = 'Your Name can only contain _, 1-9, A-Z or a-z 2-20 long.';}
  } else {$errors[] = 'You forgot to enter your Last Name.';}
 
  if (!empty($_REQUEST['email'])) {
  $lastname = $_REQUEST['email'];
  $pattern = "/^[a-zA-Z0-9\_]{2,20}{@}/";
  if (preg_match($pattern,$email)){ $email = $_REQUEST['email'];}
  else{ $errors[] = 'Your Email can only contain _, @, 1-9, A-Z or a-z 2-20 long.';}
  } else {$errors[] = 'You forgot to enter your Email.';}
 
  if (!empty($_REQUEST['mobilenumber'])) {
  $mobilenumber = $_REQUEST['mobilenumber'];
  $pattern = "/^[0-9\_]{7,20}/";
  if (preg_match($pattern,$mobilenumber)){ $mobilenumber = $_REQUEST['mobilenumber'];}
  else{ $errors[] = 'Your Mobile number can only be numbers.';}
  } else {$errors[] = 'You forgot to enter your Mobile number.';}
  }
  //End of validation
 
  if (empty($errors)) {
  $from = "From: Our Site!";
  $to = "[email protected]";
  $subject = "Admin - Our Site! Request from " . $name . "";
 
  $message = "Message from " . $firstname . " " . $lastname . "
  Email: " . $email . "
  Mobilenumber: " . $mobilenumber . "
  mail($to,$subject,$message,$from);
  }
   
  if (!empty($errors)) {
  echo '<hr /><h3>The following occurred:</h3><ul>';  
  foreach ($errors as $msg) { echo '<li>'. $msg . '</li>';}
  echo '</ul><h3>Your mail could not be sent due to input errors.</h3><hr />';}
  else{echo '<hr /><h3 align="center">Your mail was sent. Thank you!</h3><hr /><p>Below is the message that you
  sent.</p>';
  echo "Message from " . $firstname . " " . $lastname . " " . $email . "<br />Mobilephone: ".$mobilephone." <br />";
  echo "<br />Request: " . $comments . "";
 
  }
  }
//End of errors array
?>

I will appreciate your help, in any place i have made the mistake.
by
retagged by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

Welcome to Tech Support Questions, where you can ask questions and receive answers from other members of the community.

Post questions regarding any technology problem including problems with phones and tablets, computers and laptops, windows and apple devices and more. Help other members of the community by answering questions.

Note: Please do not post private information such as passwords or usernames.

5,769 questions
2,928 answers
141 comments
31,545 users