<?php $login="1"; include('header.php');

if($_SESSION['authadmin']){
echo "<script type=\"text/javascript\">window.location = \"home.php\"</script>";
exit;
} ?>

<div class="grid_full page_wrap">
<?php
	if(isset($_POST['submit'])){ 
		$user=mysql_real_escape_string($_POST['username']);
		$pass=mysql_real_escape_string($_POST['password']);
		$verify=@mysql_result(mysql_query("SELECT `password` FROM `members` WHERE `role`='1' AND `username`='$user'"),0,0); 
		if(strlen($verify) > 0 ){
			if($verify = md5($pass)){
				$_SESSION['authadmin']=$user;
				echo "<div class=\"alert alert-success\">Success ...</div>";
			echo "<script type=\"text/javascript\">window.location = \"home.php\"</script>";
			}else{
			echo "<div class=\"alert alert-error\">Wrong Username or Password</div>";
		}
	}
	}
?>
<form action="" method="POST" class="form-horizontal" style="width: 600px; margin: 0 auto;">
	
	<legend><h1>Login</h1></legend>
	<div class="control-group">
		<label class="control-label" for="inputUsername">Username</label>
		<div class="controls input-prepend">
			<span class="add-on"><i class="icon-user"></i></span><input type="text" name="username" id="inputUsername" placeholder="Username">
		</div>
	</div>
	<div class="control-group">
		<label class="control-label" for="inputPassword">Password</label>
		<div class="controls input-prepend">
			<span class="add-on"><i class="icon-lock"></i></span><input type="password" name="password" id="inputPassword" placeholder="password">
		</div>
	</div>
	<div style="text-align: center;"><input type="submit" name="submit" class="btn btn-primary btn-large" value="Save changes" style="width: 300px;"></div>
	
</form>

</div>

<?php include('footer.php'); ?>