<?php
include('database.php');
session_start();
$id= $_SESSION['id'];
$results= mysqli_query($connection, "SELECT `date`, `id`, `name`, `email`, `number`, `password`, `phone`, `address`, `country`, `gender`, `image`, `vcode`, `verified`, `verify`, `balance`, `totalbalance`, `investbalance`, `profit`, `totaldeposit`, `totalwithdrawal`, `loanlimit`, `availableloan`, `ongoingloan`, `savings`, `idcard`, `idcardback`, `accountstatus`, `pina`, `pinb`, `pinc`, `pind`, `dob` FROM users WHERE id ='$id'");
$retrive= mysqli_fetch_array($results);
$date = $retrive['date'];
$id = $retrive['id'];
$name = $retrive['name'];
$email = $retrive['email'];


$country = mysqli_real_escape_string($connection, $_POST['country']);
	
$profile = mysqli_real_escape_string($connection, $_FILES["idcard"]['name']);
    $idfile= time().'_'.$profile;
	
	  $profile2 = mysqli_real_escape_string($connection, $_FILES["idcardback"]['name']);
    $idfile2= time().'_'.$profile2;
	
    $query ="UPDATE users SET country='$country', idcard='$idfile', idcardback='$idfile2' WHERE id='$id'";
    $query_run = mysqli_query($connection, $query);
    if($query_run)
    {
		move_uploaded_file($_FILES["idcard"]["tmp_name"], "../images/user/".$idfile);
		
		move_uploaded_file($_FILES["idcardback"]["tmp_name"], "../images/user/".$idfile2);
		header('location:../index.php');
	}
    else
    {
		$_SESSION['status'] = "error..  not uploaded";
		header('location:../verify-account.php');
	}		

?>