title: php, undefined index in Validation form
body: <p>could someone please help me understand why I'm getting this notice. i tried following the tutorial <a href="https://www.youtube.com/watch?v=tRHma2JTiL4" rel="nofollow">here to create form validation</a> but i'm getting</p>
  
  <p><strong>"Notice: Undefined index: last_name in ...\workspace\Registration\registerValidation.php on line 53"</strong></p>
  
  <pre><code>    &lt;?php
  
  $errors = array();
  
  if($_SERVER['REQUEST_METHOD'] == 'POST'){
      //validation
  
      $testlName = $_POST['last_name'];       
  
      if(preg_match("([^A-Za-z0-9])", $testlName)){
          $errors['last_name'] = "Please enter a valid last name";
      }       
  
  //more validation code
  
  
  } 
  
  
  function form_row_class($name){
          global $errors;
      return $errors[$name] ? "form_error_row" : "";
  }
  
  function error_for($name){
      global $errors;
      if($errors[$name]){  //this is line 53
          return "&lt;div class='form_error'&gt;".$errors[$name]. "&lt;/div&gt;";
      }
  }    
  
  ?&gt;
  &lt;form  name="form1" method="post" action="registerValidation.php" &gt;
  &lt;table class="form"&gt;
     &lt;tr class="&lt;?php echo form_row_class("last_name") ?&gt;"&gt;
      &lt;th&gt;&lt;label for="last_name"&gt;Last Name&lt;/label&gt;&lt;/th&gt;
      &lt;td&gt;
          &lt;input name="last_name" id="last_name" type="text" size="15" maxlength="20" value="&lt;?php if(isset($testlName)){echo htmlspecialchars($_POST['last_name']);}?&gt;" /&gt;
          &lt;?php if(isset($testlName)){echo error_for('last_name');}?&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
             &lt;/table&gt;
  
  
  &lt;p&gt;&lt;input type="submit" name="submit" value="register"&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Any ideas why I'm getting that notice? I'm new to php so an explanation would be very well received, thanks!</p>
  
  <p>~Myy</p>