<?php 
class Usersetting extends baseController
{
        function Update()
            {
                $data = $this->getDataRequest();
                $newpass = $data->newpass;
                $cpass = $data->cpass;
                $qry = $this->db->query("select * from users where id=".$data->edit_id."");
                $qry->execute();
                $value = $qry->fetch( PDO::FETCH_ASSOC );
                $hash = $value['password'];
                if($cpass == $newpass):
                    $options = ['cost' => 10];			
	            	$pwd = password_hash($newpass, PASSWORD_BCRYPT, $options);
	            	$query =  $this->db->query("update users set password = '".$pwd."' where id =".$data->edit_id."");
			        echo $query ? json_encode(["status"=>"success","message"=>"Password updated successfully"]) :  json_encode(["status"=>"fail","message"=>"failed"]);
                else:
                echo json_encode(["status"=>"notmatch","message"=>"Confirm password not match"]);
                endif;
            }
}
?>