<?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'];




	  $profile = mysqli_real_escape_string($connection, $_FILES["profile"]['name']);
    $idfile= time().'_'.$profile;
	
    $query ="UPDATE users SET image='$idfile' WHERE id='$id'";
    $query_run = mysqli_query($connection, $query);
    if($query_run)
    {
		move_uploaded_file($_FILES["profile"]["tmp_name"], "../images/user/".$idfile);
		$_SESSION['status'] = "<h5 style='padding:8px; background: #1a1849; border-radius: 10px; color: #fff; text-align: center;'>PROFILE IMAGE UPLOADED</h5>";
		header('location:../profile.php');
	}
    else
    {
		$_SESSION['status'] = "error..  not uploaded";
		header('location:../profile.php');
	}		

?>