<?php
session_start();
include ("inside/config.php");
if($_REQUEST['action']=="login")
{
	$user = $_REQUEST['user'];
	$pass = $_REQUEST['pass'];
	$sql  = mysql_query("select * from `tbl_login` where `username`='$user' and `password`='$pass'");
	$rowcount = mysql_num_rows($sql);
	if($rowcount > 0)
	{
		$_SESSION['username']=$user;
		echo "<script>window.location='index.php'</script>";
	}
		else
	{
		$type = "error";
		$msg="invalid username / password.";
	}
}
	if($_REQUEST['action']=="logout")
	{
		unset($_SESSION['username']);
		$type = "ok";
		$msg = "Logout Successfully!";
	}
?>
<!DOCTYPE html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
	<title>Login Page</title>
	
	<link rel="stylesheet" type="text/css" href="css/login.css" />
</head>

<body>

	<form id="login-form" action="login.php?action=login" method="post">
		<fieldset>
		
			<legend>Log in</legend>
			
			<label for="user">User Name</label>
			<input type="text" id="user" required name="user"/>
			<div class="clear"></div>
			
			<label for="pass">Password</label>
			<input type="password" id="pass" required name="pass"/>
			<div class="clear"></div>
            <a href="#">Forgot Password?</a>		
			<br />
			
			<input type="submit" style="margin: -20px 0 0 287px;" class="button" name="commit" value="Log in"/><p style="text-decoration:blink; text-align:center; color:#FF0000"><?php echo $msg; ?></p>	
		</fieldset>
	</form>
</body>
</html>