<?php
	include_once('../config.php');   
    
  
          
    if(!isset($_SESSION['userId']))
    { 
         header("Location: ../");
         die;
    }
    
    if(isset($_POST['request_btn']))
    {        
              
            $ext = explode('.', basename($_FILES['payment_slip']['name']));//explode file name from dot(.)  
            $Fname =  substr(md5(uniqid()),26).".". $ext[count($ext) - 1];  
            $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); 
            
            $Fname = "NA";
               
            $stmt=$conn->prepare("insert into UI__FndReqt (custId,Tdate,cash,amt,slip,method) values(:custId,:Tdate,:cash,:amt,:slip,:method)  ");   
            $stmt->bindValue(':custId', $_SESSION['userId'] , PDO::PARAM_STR); 
            $stmt->bindValue(':Tdate',  date("d-M-Y"), PDO::PARAM_STR); 
            $stmt->bindValue(':cash', $_POST['payment_type'] , PDO::PARAM_STR); 
            $stmt->bindValue(':amt', $_POST['amount'] , PDO::PARAM_STR);    
            $stmt->bindValue(':slip', $Fname , PDO::PARAM_STR);   
            $stmt->bindValue(':method', $_POST['method'] , PDO::PARAM_STR);    
            $stmt->execute();      
            $_SESSION['Regis'] = "Request Updated Successfully";
            header("Location: fundrequest.php");  
            die;
    }             
                
include_once("../view/dashboard/fundrequest.php");
?>
