<?php
include "Admin/config/setup.php";
session_start();
if(isset($_POST['action'])){
    $data = [];
    $password = $config->real_escape_string($_POST['password']);
    $mas_id = $config->real_escape_string($_POST['uid']);
    $id = $config->real_escape_string($_POST['id']);
    $newpassword = password_hash($password,PASSWORD_BCRYPT);
    $new_sql = "UPDATE master_login SET Master_Password = '$newpassword', reset_link = '', reset_status = 0 WHERE Master_id = '$mas_id' ";
    if($config->query($new_sql) === TRUE){
        $status_sql = $config->query("UPDATE user_reset SET change_status = 1, status = 0 WHERE id = '$id' ");
        $chk_sql = "SELECT * FROM master_login WHERE Master_id = '$mas_id' AND Master_Type = 2 ";
        if($config->query($chk_sql)){
            $data['url'] = 'vendor_login.php';
        }else $data['url'] = 'login.php';
        $_SESSION['status'] = 'Password Changed Successfully';
        $_SESSION['alert'] = 'success';
        $data['success'] = 1;
    }else{
        $data['success'] = 0;
    }
    echo json_encode($data);
}


?>