title: PHP Update password script doesnt work
body: <p>I'm working on a website with a register system. In the userCP you can change your password. I made this script for it but it doesnt work. Can somebody help me? When I change the password it doesnt give an error but it just doesnt update it.</p>
  
  <p>PHP Code:</p>
  
  <pre><code>&lt;?php 
      if (isset($_POST['updatePassBtn']))
      {
          $cpassword = $_POST['cpassword'];
          $npassword = $_POST['npassword'];
          $rpassword = $_POST['rpassword'];
          if (!empty($cpassword) &amp;&amp; !empty($npassword) &amp;&amp; !empty($rpassword))
          {
              if ($npassword == $rpassword)
              {
                  if (mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `username` = '".$_SESSION['username']."' AND `password` = '".SHA1($cpassword)."'")))
                  {
                      mysql_query("UPDATE `users` SET `password` = '".SHA1($npassword)."' WHERE `username` = '".$_SESSION['username']."' AND `ID` = '".$_SESSION['id']."'");
                      echo '&lt;div class="nNote nSuccess hideit"&gt;&lt;p&gt;&lt;strong style="color:green;"&gt;SUCCESS: &lt;/strong&gt;Password Has Been Updated&lt;/p&gt;&lt;/div&gt;';
                  }
                  else
                  {
                      echo '&lt;div class="nNote nFailure hideit"&gt;&lt;p&gt;&lt;strong style="color:red;"&gt;FAILURE: &lt;/strong&gt;Current Password is incorrect.&lt;/p&gt;&lt;/div&gt;';
                  }
              }
              else
              {
                  echo '&lt;div class="nNote nFailure hideit"&gt;&lt;p&gt;&lt;strong style="color:red;"&gt;FAILURE: &lt;/strong&gt;New Passwords Did Not Match.&lt;/p&gt;&lt;/div&gt;';
              }
          }
          else
          {
              echo '&lt;div class="nNote nFailure hideit"&gt;&lt;p&gt;&lt;strong style="color:red;"&gt;FAILURE: &lt;/strong&gt;Please fill in all fields&lt;/p&gt;&lt;/div&gt;';
          }
      }
  ?&gt;
  </code></pre>
  
  <p>My form: </p>
  
  <pre><code>&lt;form action="" class="form" method="POST"&gt;
      &lt;fieldset&gt;
          &lt;label&gt;&lt;/label&gt;
          &lt;input name="cpassword" type="text" value="Current Password" onfocus="this.value = (this.value=='Current Password')? '' : this.value;" onblur="if(this.value == ''){this.value='Current Password';}"/&gt;
      &lt;/fieldset&gt;
      &lt;fieldset&gt;
          &lt;label&gt;&lt;/label&gt;
          &lt;input name="npassword" type="text" value="New Password" onfocus="this.value = (this.value=='New Password')? '' : this.value;" onblur="if(this.value == ''){this.value='New Password';}"/&gt;
      &lt;/fieldset&gt;
      &lt;fieldset&gt;
          &lt;label&gt;&lt;/label&gt;
          &lt;input name="rpassword" type="text" value="Repeat Password" onfocus="this.value = (this.value=='Repeat Password')? '' : this.value;" onblur="if(this.value == ''){this.value='Repeat Password';}"/&gt;
          &lt;input type="submit" value="Update" name="updatePassBtn"/&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>