<?php
	include_once('../config.php');   
    
  
          
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }
    
    if(isset($_POST['submit']))
    {   
               
               
            $stmt=$conn->prepare(" select adharcard  from UI__Rgst where custId=:custId ");    
            $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR);   
            $stmt->execute();   
            $FResult = $stmt->fetch(PDO::FETCH_OBJ);   
            unlink(ABS_PATH.'/uploads/fundReq/'.$FResult->adharcard);
            
            
            $ext = explode(".",$_FILES['payment_slip']['name']);//explode file name from dot(.)   
            $Fname =  substr(md5(uniqid()),26).".".end($ext);  
            $target_path = ABS_PATH."/uploads/fundReq/".$Fname;//set the target path with a new name of image 
            move_uploaded_file($_FILES['payment_slip']['tmp_name'], $target_path); 
            
            
            $stmt=$conn->prepare("update  UI__Rgst set  adharcard=:adharcard where custId=:custId ");    
            $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR);  
            $stmt->bindValue(':adharcard', $Fname , PDO::PARAM_STR); 
            $stmt->execute();   
            $_SESSION['Regis'] = "Adhar Updated Successfully";
            header("Location: kyc.php");  
            die;
    }         
     
             
            $stmt=$conn->prepare("select  adharcard   from  UI__Rgst where custId =:custId ");   
            $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR);  
            $stmt->execute(); 
            $FResult = $stmt->fetch(PDO::FETCH_OBJ);  
              
           
                
include_once("../view/dashboard/kyc.php");
?>
