<?php

    $request_json=$_REQUEST["data"];
    $arr = json_decode($request_json, true);
    $mobile = $arr["contact"];
    $pass = $arr["password"];
    $table = $arr["table"];
    //include 'common/connection.php';
    $servername = "localhost";
    $username = "finstech_sales";
    $password = "SalesApp@123";
    $dbname = "finstech_salesapp";
    
    
    try {
        $pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        if($table == "staff"){
            $qry = "update master_staff set password='$pass' where mobile=?";
        }
        if($table == "shop"){
            $qry = "update master_shop set password='$pass' where mobile=?";
        }
        $stmt = $pdo->prepare($qry);
        $stmt->execute([$mobile]); 
        $user = $stmt->fetch();
        
        $jsontext = "{\"status\":\"Success\"}";
        
        echo $jsontext;
    }catch(PDOException $e) {
        echo $sql . "err" . $e->getMessage();
    }
    $pdo = null;
    
?>