<?php include 'include/header.php';?>
<body>
	<div class="container">
	<div class="mx-auto col-sm-12 main-section" id="myTab" role="tablist">
		<?php include 'include/child-tab.php';?>
		<div class="tab-content" id="myTabContent">	
			<div role="tabpanel">
				<div class="card">
					<div class="card-header">
						<h4>All Author</h4>
					</div>
					<div class="card-body">
						<?php
							$id = $_GET['id_user'];
							$query = "SELECT * FROM tbl_user WHERE id_user = '".$id."'";

							$ms = mysqli_query($conn, $query);
							$result = mysqli_fetch_assoc($ms);

							if (isset($_POST['submit'])) {
							
								$name = $_POST['name_user'];    
								$email_user = $_POST['email_user'];    
								$hp = $_POST['hp'];    
								$alamat = $_POST['alamat'];    
								$lahir = $_POST['lahir'];    
								$query = "UPDATE tbl_user SET name_user = '".$name."', email_user = '".$email_user."', hp = '".$hp."', alamat = '".$alamat."', lahir = '".$lahir."' WHERE id_user = '".$id."'";
								mysqli_query($conn, $query);

								?>
									<script>
										window.location = 'users';
									</script>
								<?php
								
							}
						?>
						<form class="form" role="form" method="post" action="" enctype="multipart/form-data" autocomplete="off">
							<div class="form-group row">
								<label class="col-lg-3 col-form-label form-control-label">Name</label>
								<div class="col-lg-9">
									<input class="form-control" name="name_user" value="<?php echo $result['name_user']; ?>">
								</div>
							</div>	
							<div class="form-group row">
								<label class="col-lg-3 col-form-label form-control-label">Email</label>
								<div class="col-lg-9">
									<input class="form-control" name="email_user" value="<?php echo $result['email_user']; ?>">
								</div>
							</div>	
							<div class="form-group row">
								<label class="col-lg-3 col-form-label form-control-label">No. HP</label>
								<div class="col-lg-9">
									<input class="form-control" name="hp" value="<?php echo $result['hp']; ?>">
								</div>
							</div>	
							<div class="form-group row">
								<label class="col-lg-3 col-form-label form-control-label">Alamat</label>
								<div class="col-lg-9">
									<input class="form-control" name="alamat" value="<?php echo $result['alamat']; ?>">
								</div>
							</div>	
							<div class="form-group row">
								<label class="col-lg-3 col-form-label form-control-label">Tanggal Lahir</label>
								<div class="col-lg-9">
									<input class="form-control" name="lahir" value="<?php echo $result['lahir']; ?>">
								</div>
							</div>	
							<div class="form-group row">
								<div class="col-lg-12 text-center">
									<input type="submit" name="submit" class="btn btn-primary" value="Save">
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<?php include 'include/footer.php';?>
</body>
</html>