member can change their password
<p>I have made an script which should enable users to change their password. but i get error
confirmation password and new password doesnt match..
here is the code</p>

<pre><code>&lt;?
session_start();   
include 'db.php';

 if($_POST['username']!="") {
  $username = $_POST['username'];  
}
else die("No Username was passed");
if($_POST['password']!="") {
  $password = $_POST['password'];
}
else die("No Password was passed");
if($_POST['newpassword']!="") {
  $newpassword = $_POST['newpassword'];
}
else die("No NewPassword was passed");
if($_POST['confirmnewpassword']!="") {
  $newpassword = $_POST['confirmnewpassword'];
}
else die("No Confirm Password was passed");

$username = $_POST['username'];  
$password = $_POST['password'];
$newpassword = $_POST['newpassword'];
$confirmnewpassword = $_POST['confirmnewpassword'];

$result = mysql_query("SELECT password FROM users WHERE username='$username'");

    if(!$result){
        echo "The username entered does not exist!";
    }
    else
        if($password != mysql_result($result, 0)){
            echo "Entered an incorrect password";
            }

    if($newpassword == $confirmnewpassword){
        $sql = mysql_query("UPDATE users SET password = '$newpassword' WHERE username = '$username'");      
    }

    if(!$sql){
        echo "Congratulations, password successfully changed!";
    }
    else{
        echo "New password and confirm password must be the same!";
    }

  ?&gt;
</code></pre>

<p>here is the form Code</p>

<pre><code>&lt;form action="lostpw.php" method="post" name="" id=""&gt;
                                            &lt;table width="50%" border="0" align="center" cellpadding="4" cellspacing="0"&gt;
                                                &lt;tr&gt; 
                                                  &lt;td width="22%"&gt;Username&lt;/td&gt;
                                                  &lt;td width="78%"&gt;&lt;input name="username" type="text" id="username" value="&lt;? echo "". $_SESSION['username'] ."" ?&gt;"&gt;&lt;/td&gt;
                                                &lt;/tr&gt;
                                                &lt;tr&gt; 
                                                  &lt;td width="22%"&gt;Old password&lt;/td&gt;
                                                  &lt;td width="78%"&gt;&lt;input name="password" type="text" id="password"&gt;&lt;/td&gt;
                                                &lt;/tr&gt;
                                                  &lt;td&gt;New Password&lt;/td&gt;
                                                  &lt;td&gt;&lt;input name="newpassword" type="newpassword" value=""&gt;&lt;/td&gt;
                                                &lt;/tr&gt;
                                                &lt;tr&gt; 
                                                &lt;/tr&gt;
                                                  &lt;td&gt;Confirm &lt;/td&gt;
                                                  &lt;td&gt;&lt;input name="confirmnewpassword" type="confirmnewpassword" value=""&gt;&lt;/td&gt;
                                                &lt;/tr&gt;
                                                &lt;tr&gt; 
                                                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                                                  &lt;td&gt;&lt;input type="submit" name="Submit" value="update"&gt;&lt;/td&gt;
                                                &lt;/tr&gt;
                                                &lt;tr&gt; 
                                                  &lt;td&gt;&lt;a href="home.php"&gt;Back&lt;/a&gt;&lt;/td&gt;
                                                &lt;/tr&gt;
                                            &lt;/table&gt;
&lt;/form&gt; 
</code></pre>

<p>where am i doing wrong. </p>
