<?php
	ob_start();
	session_start();	
?>
<?php
include("config.php");
	if(isset($_SESSION["adminname"]) || isset($_SESSION["username"]))
	{
		header("Location: report1.php");
	}
?>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/sl2.css">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Admin Login</title>
		<style type="text/css">
			#powered
			{
				color: white;
				font-size: 30px;
			}
			#powered a
			{
				color: white;
				text-decoration: none;
			}
			@media(max-width: 520px)
			{
				#m_content
				{
					width: 98%;
					padding: 0px;
					height: 245px;
				}
				#m_content img
				{
					//width: 100%;
					//height: auto;
				}
				.button
				{
					width: 98%;
				}
				#m_content input.text
				{
					width: 98%;
				}
			}
			h1
			{
				font-size: 45px;
				color: #f1f6f8;
				font-weight: normal;
				padding: 0px 0 15px 0;
				margin: 0px;
				clear: both;
			}
		</style>
		
	</head>
	<body style="background-image: url('img/img7.jpg'); background-repeat: no-repeat;  width:100%">
		<form name="loginform" method="post">
			
			<?php
				
				if(isset($_POST['login']))
				{
					if(!empty($_POST["username"]) && !empty($_POST["password"]))
					{
						$username=$_POST['username'];
						$password=$_POST['password'];
						$query="SELECT * FROM user WHERE username='".$username."' LIMIT 1";
						$result=mysql_query($query);

						if(mysql_num_rows($result)!=0)
						{
							$row=mysql_fetch_array($result);
							if($password==$row["password"])
							{
								if($username=='admin'){
									$_SESSION["adminname"]=$row["username"];
								}else{
									$_SESSION["username"]=$row["username"];
								}
								//header("Location: report1.php");
                                                           ?><script>window.location='report1.php';</script><?php
							}
							else
							{
							
							$message="Username and Password do not match";
							}
						}
						else
						{
							$message="Username and Password do not match";
						}
						
					}
					else
					{
						$message="Enter Both Username and Password";
					}
				}
				
				
			?>
			<center><div id="powered" ><img src="img/excelanto_logo.png" height="100px;"></div></center>
			<div id="m_content">
				<div style="background-color: rgb(135, 136, 138);">
					
					<h1><center>BM BIO ENERGY</center></h1>
					<span style="float: right; color: red;">
						<?php
							if(isset($message))
							{
								echo $message;
							}
						?>
					</span>
				</div>
				<div>
					<input class="text" type="text" name="username" placeholder="UserName">
					<input class="text" type="password" name="password" placeholder="Password">
					<input class="button" type="submit" name="login" value="Log In">
				</div>
			</div>
		</form>
	</body>
</html>
<?php ob_flush(); ?>