<?php
	//include("login-var.php");
	//$logged = isset($enteredpw);
	
	//if ($logged) {
	//	$loggedp = "yes";
	//}
	
	$logged = empty($_POST['username']);
	
	if ($logged == false) {
		$loggedp = "yes";
		$username = $_POST['username'];
	}
	else {
		$loggedp = null;
		$username = null;
	}
?>

<!DOCTYPE HTML>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Welcome To CShop</title>
	</head>
	<body>
		<style>
			html, body {
			margin: 0;
			padding: 0;
		</style>
		
		<style>
			.header {
			  padding: 20px;
			  text-align: center;
			  background: #1abc9c;
			  color: white;
			  font-size: 30px;
			  font-family: Arial;
			}
			
			.main {
				padding-left: 15px;
				padding-top: 1px;
				padding-bottom: 1px;
			}
			
			.main-bg {
				background: #ebecf0;
			}
			
			.menu-bg {
				background: #dcdde3;
			}
		
			.img {
				float: left;
			}
			
			.clear {
				clear: both;
			}
			
			.arial {
				font-size: 20px;
				font-family: Arial;
			}
			
			.d-inline {
				display: inline;
			}
			
			.line-thru {
				text-decoration: line-through;
			}
			
			.hide {
				display: none;
			}
			
			.main-bg-row {
				background: #dedfe3;
			}
		</style>
		
		<div class="header">
			<p>Welcome To CShop !</p>
		</div>
		
		<div class="main menu-bg">
			<p class="d-inline">Login: </p> <p class="d-inline hide" id="loginmsg">You're Logged in as <?php echo $username; ?>!</p>
				<form action="login-var.php" method="POST" class="d-inline" id="loginform">
					<input type="text" name="userID" id="userID" placeholder="Username">
					<input type="password" name="userPW" id="userPW" placeholder="Password">
					<input type="submit" value="Login">
				</form>
			<p class="d-inline" id="rm">Or </p>
				<button id="rmb" onclick="window.location.href='register.html'">Register</button>
			
			<form action="changePW.php" method="POST" class="d-inline">
				<input type="hidden" name="userName" value="<?php echo $username; ?>">
				<input type="submit" value="Change Password">
			</form>
				
				<!-- Debug
				<p><?php echo $loggedp; ?></p>
				-->
			
				<br><br>
				
				<script>
					var lform = document.getElementById("loginform");
					var lmsg = document.getElementById("loginmsg");
					var rm = document.getElementById("rm");
					var rmb = document.getElementById("rmb");
					var logged = "<?php echo $loggedp; ?>";
					
					if (logged == "yes") {
						lform.style.display = 'none';
						rm.style.display = 'none';
						rmb.style.display = 'none';
						lmsg.style.display = 'inline';
					}
				</script>
		</div>
		
		<!-- Item list are inside those DIV, each DIV for an item -->
		
		<div class="main main-bg">
			<img src="pictureDB/Absen22.jpg" width="200px" class="img">
			<p class="arial">Anak cerdas 22</p>
				<p>Dengan anak cerdas 22 bisa digunakan untuk mencerdaskan anak anda juga! hebat kan?<br>
				Dapatkan benefit sebanyak banyaknya dengan melakukan pembelian item ini!</p>
				
				<form action="sellDB/Anak-Cerdas-22/index.php" method="POST" class="d-inline">
					<input type="hidden" name="username" value="<?php echo $username; ?>">
					<input type="submit" value="Buy Now">
				</form>
				<p class="d-inline"><span class="line-thru">MBC. 999.999.999.999</span> MBC. 300.000</p>
			<p class="clear"></p>
		</div>
		
		<div class="main main-bg-row">
			<img src="pictureDB/buku-kokbisa.jpg" width="200px" class="img">
			<p class="arial">Anak Cerdas 22 + Buku Kog Bisa</p>
				<p>Dengan paket bundle ini maka si cerdas 22 anda akan menjadi lebih semangat dalam<br>
				memberikan benefit sebanyak banyaknya, dapatkan benefitnya sekarang juga dengan melakukan pembelian item ini!</p>
				
				<form action="sellDB/Anak-Cerdas-22-bundle/index.php" method="POST" class="d-inline">
					<input type="hidden" name="username" value="<?php echo $username; ?>">
					<input type="submit" value="Buy Now">
				</form>
				<p class="d-inline"><span class="line-thru">MBC. 999.999.999.999</span> MBC. 400.000</p>
			<p class="clear"></p>
		</div>
	</body>
</html>