<?php
include '../config/index.php';
include '../module/index.php';
 
$data = new Database;

$con = $data->connect();

$user = new User($con);


$post = filter_var_array($_POST,FILTER_SANITIZE_FULL_SPECIAL_CHARS);

$current_pass            = $post['cpassword'];
$new_password            = $post['npassword'];
$confirm_password        = $post['cnpassword'];

if($current_pass != $_SESSION['password']){
   $_SESSION['t_error_c']  = 'incorrect password';
   echo $data->redirect('../account/../index?reset=reset');
}else{
 $_SESSION['t_error_cs']  = 'password successfully reseted, you will  be logout in 3 seconds';

echo $user->changepassword($new_password);

echo $data->redirect('../logout.php');
}

?>