well, once the user is logged in (never allow a password change without logging in first), like you said, you have the form where they enter their current password, along with the new password - twice, to ensure they enter what they want without error.
Once submitted, verify that the old password matches what is currently in the db.
Next, make sure the two entries for the new password match.
Now, simply update their password in the db.