<?php
include("../config/config.php");
include("includes/functions.php");
?>
<?php
if ( isset($_POST['loginSubmit']) )
{ // if Login form is submitted

	$password = clean($_POST['password']);
	
	$getUserInfo = mysql_fetch_array(mysql_query("SELECT id, password FROM  tbl_login WHERE Password = '".$password."'"));
	
	if(!empty($getUserInfo['id']))
	{
		$_SESSION['user_login_id'] = $getUserInfo['id'];
		$_SESSION['password'] = $getUserInfo['password'];
		$reDirUrl = STATE_URL;
	}
	else
	{
		$reDirUrl = STATE_URL.'login.php';
		$_SESSION['errorMessage'] = 1;
	}
	header("Location: $reDirUrl");
	exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login To Statistics Dashboard</title>
<link rel="stylesheet" type="text/css" href="css/login.css" />
<script src="js/jquery-1.7.min.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/login.js" type="text/javascript"></script>

</head>

<body>
	<?php
		if ( isset($_SESSION['errorMessage']) )
		{
			errorMsg($_SESSION['errorMessage']);
			unset($_SESSION['errorMessage']);
		}
		if ( isset($_SESSION['succesMessage']) )
		{
			successMsg($_SESSION['succesMessage']);
			unset($_SESSION['succesMessage']);
		}
	?>
    <div class="loginform">
        <div class="title"> <img src="images/vote.png" width="70" height="65" style="padding-top:2px;" /></div>
        <div class="form_wrapper" id="form_wrapper">
            <form id="loginInForm" name="loginInForm" method="post" action="" class="login active">
                <label class="log-lab">Password </label>
                <input name="password" type="password" id="password" placeholder="password" />
                <input type="submit" name="loginSubmit" id="loginSubmit" value="Login" class="button" />
            </form>
        </div>
    </div>
</body>
</html>