<?php session_start(); ?>
<html>
<head>
<title>Check Login</title>
<style>
		
#bg{
		margin:auto;
		width:830px;		
		padding:5px;
		font-size: 20px;
		color: crimson;
		background:#ddf;
	    border:2px solid rgba(186,186,186,1.00);
}
#bg a{
		border-collapse: collapse;
		font-family: Gill Sans, Gill Sans MT, Myriad Pro, DejaVu Sans Condensed, Helvetica, Arial," sans-serif";
}

</style>
</head>

<?php
	//session_start();
	include("functions/dblink.php");

	$password=$_POST['txtPassword'];
	
	$sql = "SELECT * FROM member WHERE Username ='".mysqli_real_escape_string($con,$_POST['txtUsername'])."'
	and Password ='".mysqli_real_escape_string($con,$password)."'";
	$query = mysqli_query($con,$sql);
	$result = mysqli_fetch_array($query,MYSQLI_ASSOC);
	if(!$result)
	{
		?>
		<div id="bg" align="center" >	
				<!-- <p>Username and Password Incorrect !</p> -->
				<p>ชื่อผู้ใช้ และรหัสผ่าน ไม่ถูกต้อง !</p>
				<br>
				<a href="login.php" style="text-decoration: none">Login</a>
		</div>			
		<?php		
	}
	else
	{
			$_SESSION["UserID"] = $result["UserID"];
        	$_SESSION["UserName"]=$result["Username"];
			$_SESSION["Status"] = $result["Status"];
        		
			session_write_close();
			
			if($result["Status"] == "ADMIN")
			{
				//header("location:admin_page.php");
				session_start();
				$mainLayoutContent = "page-content/seller/index.php";
				include "layout/mainLayout.php";
			}
			else
			{
				//header("location:user_page.php");
				session_start();
				$mainLayoutContent = "page-content/seller/index.php";
				include "layout/mainLayoutOther.php";
			}
	}
	mysqli_close($con);
?>
</html>