title: PHP Fatal error: Call to undefined function test_input() in C:\wamp\www\web\new9.php on line 11
body: <p>The following form shows an error on clicking the submit button if we enter the name only and submit.The error shown is <br/><br/>
   Fatal error: Call to undefined function test_input() in C:\wamp\www\web\new9.php on line 11 <br/></p>
  
  <h2>Can anyone find the problem in the below code.</h2>
  
  <pre><code>      &lt;?php
  // define variables and set to empty values
  $name1Err = $email1Err  =  "";
  $name1 = $email1 =  "";
  
  if ($_SERVER["REQUEST_METHOD"] == "POST")
  {
   if (empty($_POST["input_1"]))
      {$name1Err = "Your name is required. Just the first will do. ";}
    else
      {$name1 = test_input($_POST["input_1"]);
       if (!preg_match("/^[a-zA-Z ]*$/",$name1))
         {       $name1Err = "Only letters and white space allowed"; }
      }
  
   if (empty($_POST["input_12"]))
      {$email1= "";}
    else
      {$email1 = test_input($_POST["input_12"]);
      // check if e-mail address syntax is valid
       if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email1))
         {  $emailErr = "Invalid email format"; }
      }
  
  
  
  
  function test_input($data)
  {
     $data = trim($data);
     $data = stripslashes($data);
     $data = htmlspecialchars($data);
     return $data;
  }
  }
  ?&gt;
          &lt;form method='post' enctype='multipart/form-data' action=''&gt;
                  name&lt;input name='input_1' type='text' value='&lt;?php echo $name1;?&gt;' tabindex='1' /&gt;
                  &lt;div class="validation_message"&gt;&lt;?php echo $name1Err ?&gt;&lt;/div&gt;
  
                  email&lt;input name='input_12'  type='email' value='&lt;?php echo $email1;?&gt;'/&gt;&lt;br/&gt;
                  &lt;textarea name='input_5' tabindex='9'   rows='10' cols='50'&gt;&lt;/textarea&gt;
  
              &lt;input type='submit' value='Submit' tabindex='25' /&gt;
  
      &lt;/form&gt;
  
  
  &lt;?php
  echo "&lt;h2&gt;Your Input:&lt;/h2&gt;";
  echo "Name:".$name1;
  echo "&lt;br&gt;";
  echo "Email:".$email1;
  echo "&lt;br&gt;";
  ?&gt;
  </code></pre>