trying to change password,but dunno wat adjusmnts to make on my code

$dbhost = "localhost";
$dbname = "phplogin";
$dbuser = "root";
$dbpass = "";
$conn = mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname, $conn) or die(mysql_error());
@$username = $_POST['username'];
@$password = $_POST['password'];
 mysql_query("UPDATE mysql.user SET Password = PASSWORD('$password') WHERE User='$username'");
  echo("Password changed.");
?>  <fieldset><h1><b>Change Or Reset Your Password!!<b></h1>
<form action='change2.php' method='POST'>
    <td>Old password:</td> </label><td><input type='text' name='oldpassword'></td></tr>
<label><tr><td>New password:</td> </label><td><input type='password' name='newpassword'></td></tr>
    <label><tr><td>Repeat New password: </label><input type='password' name='repeatnewpassword'></td></tr>
    <tr><td><input type='submit' name='submit' value='change password'></td></tr></table>

What exactly do you want to happen? The code for change2.php is similar to the above, but the query needs to check if the password matches too.

well the basic html outine is :-

Enter your Current password:-[                    ]
Enter new password:-[                 ]
Confirm New password:-[              ]

now first of all it should check for whether the correct password field is correct or not
2)then i should be check whether the newpassword and confirmnew password fields are same or not
3)if everythng goes well then the password of that particular user gets change in my mysql database..else return respective error messages.@prit

  1. Checking if it's correct can be done with a SELECT, almost identical to the UPDATE above.

  2. That's a simple string comparison $new === $repeatnew (=== for safety, although you should check whether or not they are empty too).

  3. Same UPDATE as above, with the new password.