title: PHP: change password
body: <p>I am implementing a password change function for my website. Unofortunately it doesn't work. </p>
  
  <p>In the .html file I got the code: </p>
  
  <pre><code> &lt;form method='post' &gt;
                      &lt;td&gt;Old Password:&lt;/td&gt;                  
                      &lt;td&gt;&lt;input name='oldpw' type='password' required='required'/&gt;&lt;/td&gt;
                  &lt;tr&gt;
                      &lt;td&gt;New Password:&lt;/td&gt;
                      &lt;td&gt;&lt;input name='newpw' type='password' required = 'required' /&gt;&lt;/td&gt;
                  &lt;tr&gt;                    
                      &lt;td&gt;Confirm Password:&lt;/td&gt;                  
                      &lt;td&gt;&lt;input name='conpw' type='password' required = 'required' /&gt;&lt;/td&gt;
                      &lt;td&gt; 
                      &lt;input type='submit' value='Change Password' /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;           
                   &lt;/form&gt;
  </code></pre>
  
  <p>In the account.php file I wrote this:</p>
  
  <pre><code>if (isset($_POST['newpw'])){
  
      $pw=$dbc-&gt;query("select passwort from kundenaccount where accname= '" . $_SESSION['accname'] . "';")
                  $row = $pw-&gt;fetch_object()
                  $pawo = $row-&gt;passwort 
  
          if (md5($_POST['oldpw']) == $pawo){
          if ($_POST['newpw']==$_POST['conpw']){
           $dbc-&gt;query("UPDATE accname SET passwort='" . md5($_POST['newpw']) . "' WHERE accname='" . $_SESSION['accname'] . "';")
           }
          else { echo "Passwords do not match" }
          }
      else { echo "Wrong password entered"}
      }
  </code></pre>
  
  <p>Do anyone see my mistake? I try to solve this problem since days.. </p>
  
  <p>Hope anyone can help. </p>
  
  <p>Thanks</p>