title: Undefined index in PHP in gender
body: <p>I'm very as in very new to PHP.
  There's this error: <strong>Notice: Undefined index: gender in C:\xampp\htdocs\exer1\exer1_process.php on line 6</strong></p>
  
  <p>By looking at it, I know it got to do something with the gender.
  I tried searching and looking for the error, but I just don't get it.
  Please help me.</p>
  
  <p>This is the code:</p>
  
  <p>Process.php</p>
  
  <pre><code>    &lt;?php
  
      $fname = $_POST['fname'];
      $mname = $_POST['mname'];
      $lname = $_POST['lname'];
      $gender = $_POST['gender'];
      $age = $_POST['age'];
      $status = $_POST['status'];
      $connum = $_POST['connum'];
      $studnum = $_POST['studnum'];
      $pre = 'Mr.';
  
  
      /** is_numeric validates digits
          strlen validates char lengths
      **/
  
      /** ctype_digit for numbers(?)
          ctype_alpha for letters(?)
      **/
  
      if (empty($fname)){
      echo "&lt;b&gt;&lt;font color='red'&gt;First name is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
      if (ctype_digit($fname)){
          echo '&lt;b&gt;&lt;font color="red"&gt;First name must be alphabet only!!&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $fname="";
          }
          }
  
      if (empty($mname)){
      echo "&lt;b&gt;&lt;font color='red'&gt;Middle name is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
      if (ctype_digit($mname)){
          echo '&lt;b&gt;&lt;font color="red"&gt;Middle name must be alphabet only!!&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $mname="";
          }
          }
  
      if (empty($lname)){
      echo "&lt;b&gt;&lt;font color='red'&gt;Last name is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
      if (ctype_digit($lname)){
          echo '&lt;b&gt;&lt;font color="red"&gt;Last name must be alphabet only!!&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $lname="";
          }
          }
  
      if (empty($age)){
      echo "&lt;b&gt;&lt;font color='red'&gt;Age is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
          if (!is_numeric($age)){
          echo '&lt;b&gt;&lt;font color="red"&gt;Age must only be numeric!!&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $age='&lt;font color="red" size="1"&gt;error&lt;/font&gt;';
          }
          }
  
      if (empty($gender)){
      echo "&lt;b&gt;&lt;font color='red'&gt;Gender is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
      if ($gender=='female') {
              if ($status=='married') {
              $pre='Mrs.';
              } else {
              $pre='Ms.';
              }
              }
              }
  
      if ($status=="def"){
      echo "&lt;b&gt;&lt;font color='red'&gt;Status is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      $status="";
      }
  
      if (empty($connum)){
      echo "&lt;b&gt;&lt;font color='red'&gt;Contact number is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
          if (!is_numeric($connum)){
          echo '&lt;b&gt;&lt;font color="red"&gt;Contact number must only be numeric!!&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $connum='&lt;font color="red" size="1"&gt;error&lt;/font&gt;';
          }
  
      if (strlen($connum)&lt;7){
          echo '&lt;b&gt;&lt;font color="red"&gt;Invalid Input! Contact number must be at least 7 digits.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $connum='&lt;font color="red" size="1"&gt;error&lt;/font&gt;';
          } 
          }
  
      if (empty($studnum)){
      echo "&lt;b&gt;&lt;font color='red'&gt;Student number is required.&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;";
      } else {
          if (!is_numeric($studnum)){
          echo '&lt;b&gt;&lt;font color="red"&gt;Student number must only be numeric!!&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;';
          $studnum='&lt;font color="red" size="1"&gt;error&lt;/font&gt;';
          }
          }
  
  
      if(isset($_POST['submit'])) {
  
      echo '&lt;b&gt;Firstname: &lt;/b&gt;'.$fname.'&lt;br/&gt;';
      echo '&lt;b&gt;Middlename: &lt;/b&gt;'.$mname.'.'.'&lt;br/&gt;';
      echo '&lt;b&gt;Lastname: &lt;/b&gt;'.$lname.'&lt;br/&gt;';
      echo '&lt;b&gt;Your Fullname: &lt;/b&gt;'.$pre.' '.ucfirst($fname).' '.ucfirst($mname).'.'.' '.ucfirst($lname).'&lt;br/&gt;';
      echo '&lt;b&gt;Age: &lt;/b&gt;'.$age.'&lt;br/&gt;';
      echo '&lt;b&gt;Gender: &lt;/b&gt;'.strtoupper($gender).'&lt;br/&gt;';
      echo '&lt;b&gt;Status: &lt;/b&gt;'.strtoupper($status).'&lt;br/&gt;';
      echo '&lt;b&gt;Contact #: &lt;/b&gt;'.$connum.'&lt;br/&gt;';
      echo '&lt;b&gt;Student #: &lt;/b&gt;'.$studnum.'&lt;br/&gt;';
      echo 'If I am not mistaken, you started college year&lt;b&gt;'.' '.substr($studnum,0,4).'&lt;/b&gt;.'.'&lt;br&gt;';
  
      }
  
  
  
  ?&gt;
  </code></pre>