title: IF Else is failing me
body: <p>I keep getting my error that I have to enter both new passwords correctly in my code. Thats not what I want. IF the password field is filled out, then it should check for the password matches and fits the requirements. Otherwise, it should update the profile. But its not doing that. IT still checks for the password field. Can you tell me what I am doing wrong with my code? </p>
  
  <pre><code>    &lt;?php
      if ($post == "yes") {
  
  
      $uppercase = preg_match('@[A-Z]@', $password);
      $lowercase = preg_match('@[a-z]@', $password);
      $number    = preg_match('@[0-9]@', $password);
  
      if (isset($password) &amp;&amp; ($password != $password2 || !$uppercase || !$lowercase ||    !$number || strlen($password) &lt; 8)) {
      echo "&lt;table class=tablenews&gt;&lt;tr&gt;&lt;td&gt;There is an error with your passwords. Either they do not match, or your new password does not contain 8 characters, a number, a lower and an upper case letter. Go back and retry again. &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
  
      }
  
      else {
       $password = generateHash($password);
  
      $result = mysql_query("UPDATE users SET avatar='" . $avatar . "' WHERE id='". $_SESSION['user_id'] . "'") 
      or die(mysql_error());  
      $result = mysql_query("UPDATE users SET u_signature='" . $signature . "' WHERE id='".   $_SESSION['user_id'] . "'") 
       or die(mysql_error()); 
      $result = mysql_query("UPDATE users SET u_bio='" . $bio . "' WHERE id='".    $_SESSION['user_id'] . "'") 
      or die(mysql_error()); 
      $result = mysql_query("UPDATE users SET u_desc='" . $desc . "' WHERE id='". $_SESSION['user_id'] . "'") 
      or die(mysql_error()); 
      $result = mysql_query("UPDATE users SET u_intro='" . $intro . "' WHERE id='".     $_SESSION['user_id'] . "'") 
      or die(mysql_error()); 
          $result = mysql_query("UPDATE users SET password='" . $password . "' WHERE id='". $_SESSION['user_id'] . "'") 
  or die(mysql_error()); 
  printf('&lt;script&gt;window.location = "http://www.sw-bfs.com/index.php?siteid=profileedit"&lt;/script&gt;');
  }
  
      if (!isset($password)) {
  $result = mysql_query("UPDATE users SET avatar='" . $avatar . "' WHERE id='". $_SESSION['user_id'] . "'") 
  or die(mysql_error());  
  $result = mysql_query("UPDATE users SET u_signature='" . $signature . "' WHERE id='". $_SESSION['user_id'] . "'") 
  or die(mysql_error()); 
  $result = mysql_query("UPDATE users SET u_bio='" . $bio . "' WHERE id='". $_SESSION['user_id'] . "'") 
  or die(mysql_error()); 
  $result = mysql_query("UPDATE users SET u_desc='" . $desc . "' WHERE id='". $_SESSION['user_id'] . "'") 
  or die(mysql_error()); 
  $result = mysql_query("UPDATE users SET u_intro='" . $intro . "' WHERE id='". $_SESSION['user_id'] . "'") 
  or die(mysql_error()); 
  
  
  
      printf('&lt;script&gt;window.location = "http://www.sw-bfs.com/index.php?siteid=profileedit"&lt;/script&gt;');
  
  }
  
  
  }
  
  else {
  ?&gt;
  
  &lt;table class="tablenews"&gt;
  &lt;tr&gt;&lt;th&gt;Edit your Profile&lt;/th&gt;&lt;/tr&gt;
  
  &lt;?php
  $userfinalid = $_SESSION['user_id'];
  $prAvatar = get_user_data($userfinalid, avatar);
  $prSignature = get_user_data($userfinalid, signature);
  $prBio = get_user_data($userfinalid, bio);
  $prDesc = get_user_data($userfinalid, desc);
  $prIntro = get_user_data($userfinalid, intro);
  ?&gt;
  
  &lt;br&gt;&lt;tr&gt;&lt;td&gt;
  &lt;form method="post" action="&lt;?php echo $thispage . "?siteid=profileedit"; ?&gt;&amp;proc=New&amp;post=yes&amp;&lt;?php echo $pagevars; ?&gt;"&gt;
  
  &lt;?php
  
  echo '&lt;label for="avatar" class=customlabelname&gt;Avatar Link:&lt;/label&gt;&lt;br&gt;&lt;input type="text" class=customlabel name="avatar" value="' . $prAvatar .'"&gt;&lt;br&gt;';
  echo '&lt;label for="bio" class=customlabelname&gt;User Bio:&lt;/label&gt;&lt;br&gt;&lt;textarea rows="10" cols="40" class=customlabel name="bio"&gt;' . $prBio .'&lt;/textarea&gt;&lt;br&gt;';
  echo '&lt;label for="desc" class=customlabelname&gt;User Description:&lt;/label&gt;&lt;br&gt;&lt;textarea rows="10" cols="40" class=customlabel name="desc"&gt;' . $prDesc .'&lt;/textarea&gt;&lt;br&gt;';
  echo '&lt;label for="intro" class=customlabelname&gt;User PM Intro:&lt;/label&gt;&lt;br&gt;&lt;textarea rows="10" cols="40" class=customlabel name="intro"&gt;' . $prIntro .'&lt;/textarea&gt;&lt;br&gt;';
  echo '&lt;label for="signature" class=customlabelname&gt;User Signature:&lt;/label&gt;&lt;br&gt;&lt;textarea rows="10" cols="40" class=customlabel name="signature"&gt;' . $prSignature .'&lt;/textarea&gt;&lt;br&gt;';
  echo '&lt;label for="password" class=customlabelname&gt;New Password(Leave Blank if it will be the same):&lt;/label&gt;&lt;input type=password rows="10" cols="40" class=customlabel name="password"&gt;&lt;/textarea&gt;&lt;br&gt;';
  echo '&lt;label for="password2" class=customlabelname&gt;ReType Password:&lt;/label&gt;&lt;input type=password rows="10" cols="40" class=customlabel name="password2"&gt;&lt;/textarea&gt;&lt;br&gt;';
  echo '&lt;input type=submit value="submit" class=button2&gt;';
  ?&gt;
  
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;?php
  }
      ?&gt;
  </code></pre>