$hash_md5=md5($salt.$pass);// md5 hash with salt #2
$hash_md5_double=md5(sha1($salt.$pass));// md5 hash with salt & sha1 #3
if(!strcmp($hash_md5_double,$saved_hash)&&!strcmp($newpasswd,$confirmpasswd)&&!strcmp($_POST["user"],$_SESSION['myusername'])){//old password is correct && new and confirm are the same
//set the new one
$pass=$confirmpasswd;
$hash=md5($pass);// md5 hash #1
$hash_md5=md5($salt.$pass);// md5 hash with salt #2
$hash_md5_double=md5(sha1($salt.$pass));// md5 hash with salt & sha1 #3
//Save in file
//We save the changes in a temporarely file in /tmp
$old_value=$username." ".$saved_hash;
$new_value=$username." ".$hash_md5_double;
$output=shell_exec('cat '.$GLOBALS['phpusersfile'].' | sed -i "s/'.$old_value.'/'.$new_value.'/g" '.$GLOBALS['phpusersfile']);//replace password for the user