<?php
session_start(); 
require_once 'backend/class.admin.php';
include_once ('backend/session.php');


if (!isset($_SESSION['uname'])) {
    header("Location: user_login.php");
    exit();
}

 
$reg_user = new USER();

$stmt = $reg_user->runQuery("SELECT * FROM account WHERE uname=:uname");
$stmt->execute(array(":uname" => $_SESSION['uname']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);


$email = $row['email'];

$temp = $reg_user->runQuery("SELECT * FROM transfer WHERE email = '$email' ORDER BY id DESC LIMIT 3");
$temp->execute(array(":uname" => $_SESSION['uname']));
$rows = $temp->fetch(PDO::FETCH_ASSOC);



// If upload button is clicked ...
  if (isset($_POST['upload'])) {
 
     $acc_name =$_POST['acc_name'];
      $email =$_POST['email'];
    $filename = $_FILES["uploadfile"]["name"];
    $tempname = $_FILES["uploadfile"]["tmp_name"];   
        $folder = "backend/pic/".$filename;
	
 
	$db = mysqli_connect("$host", "$username", "$password", "$database");

		 
         
        // Now let's move the uploaded image into the folder: image
    $stmt = $reg_user->runQuery("SELECT * FROM account_kyc WHERE acc_name=:acc_name");
    $stmt1 = $reg_user->runQuery("SELECT * FROM account_kyc WHERE filename=:filename");
    $stmt->execute(array(":acc_name" => $acc_name));
    $stmt1->execute(array(":filename" => $filename));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $row1 = $stmt1->fetch(PDO::FETCH_ASSOC);


    if ($stmt->rowCount() > 0 || $stmt1->rowCount() > 0) {
        $msg = "
		      <div class='alert alert-danger'>
				 
				<center>	<strong style='color:white'>You Have Submitted before wait for Approval!</strong></center>
			  </div>
			  ";
    } else {
    
    // Get all the submitted data from the form 
 $sql = "INSERT INTO `account_kyc` (`id`, `acc_name`, email, `filename`)  VALUES (NULL, '$acc_name', '$email', '$filename')";
     
        // Execute query
        mysqli_query($db, $sql);
     if (move_uploaded_file($tempname, $folder))  {
            			$msg = "
					<div class='alert alert-success'>
					
					<script type='text/javascript'>
							<!--
							function Redirect() {
							window.location='verification2.php';
							}
							document.write ('');
							setTimeout('Redirect()', 3000);
							//-->
							</script>
							
					<center><img src='icon/loading.gif' width='180px'  /></center>
					
                    
					<center>	<strong style='color:white;'>ID Card Uplaoded Successfully
                           </strong></center>
			  		</div>
					";
        
 
         
         
     }
        
        else{
            $msg = "
            <div class='alert alert-success'>
					<center>	<strong style='color:black;'>Customer Verification Failed, Try Again Later
                           </strong></center>
			  		</div> ";
      }
  }
  $result = mysqli_query($db, "SELECT * FROM image");


}
	
?>


<html>

<head>
  <link rel="stylesheet" href="css/style.css">
  <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
 <title> Know Your Customer Verification <?php echo $site_title; ?>   - Credit Cards, Banking, Loans and Mobile Payments
  </title>
  
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
 <!-- Place favicon in the favicon directory -->
  <link rel="shortcut icon" href="images/favicon.png" />
  <style>

        body {
        background-image:url('slider-bg3.jpg');  ; 
      
        font-family: 'Ubuntu', sans-serif;
    }
    
    .main {
        background-color: #0b4575;
        width: 340px;
        height: 500px;
        margin: 7em auto;
        border-radius: 1.5em;
        box-shadow: 0px 11px 35px 2px rgba(0, 0, 0, 0.14);
    }
    
    .sign {
        padding-top: 40px;
        color: green;
        font-family: 'Ubuntu', sans-serif;
        font-weight: bold;
        font-size: 14px;
    }
    
    .un {
    width: 70%;
    color: rgb(38, 50, 56);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    background: rgba(136, 126, 126, 0.04);
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    outline: none;
    box-sizing: border-box;
    border: 2px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 50px;
    margin-left: 46px;
    text-align: center;
    margin-bottom: 27px;
    font-family: 'Ubuntu', sans-serif;
    }
    
    form.form1 {
        padding-top: 40px;
    }
    
    .pass {
            width: 76%;
    color: rgb(38, 50, 56);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
    background: rgba(136, 126, 126, 0.04);
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    outline: none;
    box-sizing: border-box;
    border: 2px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 50px;
    margin-left: 46px;
    text-align: center;
    margin-bottom: 27px;
    font-family: 'Ubuntu', sans-serif;
    }
    
   
    .un:focus, .pass:focus {
        border: 4px solid rgba(253, 253, 253, 0.18) !important;
        color:white;
        
    }
    
    .submit {
      cursor: pointer;
        border-radius: 5em;
        color: #fff;
        background: linear-gradient(to right, #ea8315, #ea8315);
        border: 0;
        padding-left: 40px;
        padding-right: 40px;
        padding-bottom: 10px;
        padding-top: 10px;
        font-family: 'Ubuntu', sans-serif;
        margin-left: 28%;
        font-size: 13px;
        box-shadow: 0 0 20px 1px rgba(0, 0, 0, 0.04);
    }
    
    .forgot {
        text-shadow: 0px 0px 3px rgba(117, 117, 117, 0.12);
        color: #E1BEE7;
        padding-top: 15px;
    }
    
    a {
        text-shadow: 0px 0px 3px rgba(117, 117, 117, 0.12);
        color: #E1BEE7;
        text-decoration: none
    }
    
    @media (max-width: 600px) {
        .main {
            border-radius: 0px;
        }
        
        
</style>

</head>

<body>
  
                
 
	 <div class="main">
	<p>&nbsp;</p>
	     
                      <p align="center">  <strong style="color:white;">Hello, <?php echo $row['fname']; ?></strong>,<br>
                     <strong class="text-header text-decoration" style="COLOR:white">Please Upload your Identity Card</strong>  
                     
                     </p>
                       <center><img src="icon/kyc.gif" height="200px"/></center>
 
                    <?php if (isset($msg)) echo $msg; ?>
                        <form class="form1" method="POST" enctype="multipart/form-data">
                            
                     
                            <input class="form-control form-control-lg box-rounded-right" name="acc_name" value="<?php echo $row['fname']; ?> <?php echo $row['lname']; ?>" type="hidden" placeholder="" readonly>
<input  name="email" value="<?php echo $row['email']; ?>" type="hidden" >


                            <input  class="un " name="uploadfile" type="file" autofocus required />

                        <button type="submit"  name="upload"   class="submit" align="center" >SUBMIT</button>
                        <footer class="">
                           <p style="text-align: center;"><a  style="color:white;"href="logout.php">Login Page</a></p>

                        </footer>
             </div>    </div>



                </form>
     
</body>

</html>