That way has some security issue's involved. You would want to have 2 forms. One for Current Password, and one for New Password. That way, if they put in the $id for another username, they would have to know that persons original p/w.
You will need 2 files. One for the form, and one for the action the form takes.
newpw.php // This is the form page
<?
include "db.php"; // connect
$result = mysql_query("SELECT * FROM table WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="newpw2.php?userid=<? echo $myrow["id"];?>">
<input type="hidden" name="id" value="<? print($myrow["id"]);?>">
<b>Current Password:</b><br>
<input type='text' name='currentpw'><br>
<b>New Password:</b><Br>
<input type='text' name='newpw'><br>
<input type="Submit" value="Update information"></form>
newpw2.php // This is the action the form takes
<?
include "db.php"; // Connection to DB
$result = mysql_query("SELECT * FROM table WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
$user_pass = $myrow["user_pass"];
$currentpw2 = md5($myrow["currentpw"];
?>
<?
if ($currentpw2 != $user_pass) {
echo "Sorry, The current password you entered does not match the current password now. Please re-enter the data and try to change your password again.";
} else {
include "db.php"; // Connection to DB
$newpw2 = md5($newpw);
mysql_query("UPDATE users SET user_pass='$newpw2' WHERE id='$id'");
echo "Thank you! Password Changed!.";
}
?>
Maybe that helped you.. That is what I use, but a little different.