<?php
	session_start();
	if($_SESSION['kbuid'])
	{
		$userid= $_SESSION['kbuid'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
	include'connection.php';
	
	$reGetUser=mysqli_query($con,"SELECT * FROM user WHERE Userid='$userid'");
	$dataGetUser=mysqli_fetch_array($reGetUser);
	
	if(isset($_POST['submit']))
	{	
		$filename=$_FILES['upload']['name'];
		$location=$_FILES['upload']['tmp_name'];
		
		$store = "imgPro/".$filename;
		move_uploaded_file($location,$store);
		
		if($reUpdate=mysqli_query($con,"UPDATE user SET imgName='$filename', imgUrl='$store'"))
		{
			echo "<div class='msg-div'>
					<form method='post'>
					<h3>Profile has been changed successfully !</h3><br>
					<i class='fa fa-check-circle' aria-hidden='true' id='okIcon'></i><br><br>
					<button type='submit' class='btnPopup'>OK</button><br><br>
					</form>
				</div>";
		}
		else
		{
			echo "<script>alert('Somthing Error !'); </script>";
		}
	}
?>
<html>
<head>
	<title>Change Profile Picture</title>
	<!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	
	<!-- Admin CSS File Link -->
	<link rel="stylesheet" href="css/style.css">
	
	<!-- Font Awesome Icone -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	
	<style>
		.div1{
			background:#f7f7f7;
			width:50%;
			height:500px;
			float:left;
			text-align:center;
		}
		.subDiv1{
			background:green;
			color:white;
			width:30%;
			height:40px;
			line-height:40px;
			margin:15px 0px 0px 10px;
			border-radius:;
			font-size:18px;
			float:left;
		}
		.subDiv1Add{
			background:green;
			color:white;
			width:30%;
			height:100px;
			line-height:100px;
			margin:10px 0px 10px 10px;
			border-radius:;
			font-size:19px;
			float:left;
		}
		.subDiv2{
			color:white;
			width:64%;
			height:40px;
			line-height:40px;
			margin:15px 0px 0px 0px;
			border-radius:;
			font-size:19px;
			float:left;
		}
		
		.subDiv2Add{
			color:white;
			width:64%;
			height:100px;
			line-height:100px;
			margin:10px 0px 10px 0px;
			border-radius:;
			font-size:19px;
			float:left;
		}
		.div1 input, .div1 select, .div1 p{
			color:black;
			text-align:left;
			width:100%;
			height:40px;
			margin:0px;
			padding:2px 10px;
			border:1px solid green;
			font-size:17px;
		}
		input[type=file]
		{
			border:none;
		}
		.div1 textarea{
			width:100%;
			height:100px;
			padding:2px 10px;
			border:1px solid green;
			font-size:19px;
		}
		.divImg{
			background:white;
			width:94%;
			height:100px;
			margin:15px 10px;
			padding:8px;
			border:1px solid green;
			font-size:19px;
			text-align:left;
		}
		.divImg img{
			width:19%;
			height:80px;
			float:left;
		}
		.divImg input{
			width:70%;
			float:right;
			font-size:15px;
		}
		input[type=submit]{
			background:green;
			width:94%;
			margin:15px 10px 10px 0px;
			padding:2px;
			color:white;
			font-size:25px;
			transition:1s;
			text-align:center;
		}
		input[type=submit]:hover{
			background:white;
			color:green;
			border:1px solid green;
			cursor:pointer;
			transition:1s;
		}
		
		@media(max-width:768px)
		{
			.div1{
				width:100%;
				height:auto;
			}
			.nav,.container{
				height:auto;
			}
		}
	</style>
	
	<link rel="stylesheet" href="css/mediaStyle.css">
</head>
<body>
	<!--Header Divison-->
	<?php
		require'header.php';
	?>
	
	<!--Container Division-->
	<div class="container">
		<?php
			include'menu.php';
		?>
		<div class="content">
			<div class="head">
				<div class="title"><p>Change Profile Picture:-</p></div>
				<div class="msg"><marquee>This Is Test Message</marquee></msg>
			</div><hr>
			<div class="data-content">
				<form method="post" enctype="multipart/form-data">
					<div class="div1">
						<div class="divImg"><img src="<?php echo $dataGetUser['imgUrl']; ?>"></img><input type="file" name="upload"></div>
						<input type="submit" name="submit" value="Submit" >
					</div>
				</form>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>