<?php
	include_once('../config.php');   
    
  
          
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }
    
    if(isset($_POST['submit']))
    {   
             
             
             //echo '<pre>'; print_r($_POST);
            //$stmt=$conn->prepare("update  user set nm=:nm,phm=:phm,eml=:eml,password=:password,Bname=:Bname,Bnumber=:Bnumber,Bifsc=:Bifsc,Bbranch=:Bbranch where custId=:custId ");    
            
             
            $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);   
            
            
           if(strlen($_POST['Bnumber'])>4) 
                $Bnumber = substr($_POST['Bnumber'], -4);   
            else
                $Bnumber =  $_POST['Bnumber'];
                      

            $stmt=$conn->prepare("update  UI__Rgst set  nm=:nm,phm=:phm,eml=:eml,accHolderNm=:accHolderNm,Bnumber=:Bnumber,Bname=:Bname,Bifsc=:Bifsc,Bbranch=:Bbranch,paymentSlip=:paymentSlip,UPI=:UPI,UPI2=:UPI2,UPI3=:UPI3,UPI4=:UPI4,UPI5=:UPI5  where custId=:custId ");   
            $stmt->bindValue(':nm', $_POST['Fname'] , PDO::PARAM_STR); 
            $stmt->bindValue(':phm',  $_POST['Phone'] , PDO::PARAM_STR); 
            $stmt->bindValue(':eml', $_POST['Email'] , PDO::PARAM_STR);  
            $stmt->bindValue(':custId', $_SESSION['userCustId'] , PDO::PARAM_STR); 
            $stmt->bindValue(':accHolderNm', $_POST['AccHoldernumber']  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bnumber', $Bnumber  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bname', $_POST['Bname']  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bifsc', $_POST['Bifsc']  , PDO::PARAM_STR); 
            $stmt->bindValue(':Bbranch', $_POST['Bbranch']  , PDO::PARAM_STR); 
            $stmt->bindValue(':paymentSlip', "NA" , PDO::PARAM_STR);     
            $stmt->bindValue(':UPI', $_POST['UPI'] , PDO::PARAM_STR); 
            $stmt->bindValue(':UPI2', $_POST['UPI2'] , PDO::PARAM_STR); 
            $stmt->bindValue(':UPI3', $_POST['UPI3'] , PDO::PARAM_STR); 
            $stmt->bindValue(':UPI4', $_POST['UPI4'] , PDO::PARAM_STR); 
            $stmt->bindValue(':UPI5', $_POST['UPI5'] , PDO::PARAM_STR); 
            $stmt->execute();   
            $_SESSION['Regis'] = "Profile Updated Successfully";
            header("Location: profile.php");  
            die;
    }         
     
             
            $stmt=$conn->prepare("select  *   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/profile.php");
?>
