<? include("../settings.php"); ?>
<?
    $error = false;
	if (isset($_POST['submit'])){
        $bind = array(
            ":search1" => $_POST['login'],
            ":search2" => $_POST['password']
        );
        $results = $db->select("tbl_abstract_user", "user_login = :search1 AND user_password = :search2", $bind);  
		if (count($results)){
			// Storing user id into session variable
			$_SESSION['user_id']=$results[0]['user_id'];
			$_SESSION['user_login']=$results[0]['user_login'];
			$_SESSION['user_admin']=$results[0]['user_admin'];			
			// Storing the login time
			Header("Location: main.php");
		}else
			$error=true;
	}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Abstract Submission Portal</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
<form class="form-horizontal" method="post" action="">
  <fieldset>
      <h3>Abstract Submission Portal</h3>
        <div class="well">
            <?
                if ($error){
                    echo "<div class='alert alert-dismissable alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Oh snap!</strong> Change a few things up and try submitting again.</div>";
                }
            ?>
            
            <div class="form-group">
              <label for="login" class="col-lg-4 control-label">Login ID</label>
              <div class="col-lg-6">
                <input type="text" class="form-control" id="login" name="login" placeholder="Login ID">
              </div>
            </div>    
            <div class="form-group">
              <label for="password" class="col-lg-4 control-label">Password</label>
              <div class="col-lg-6">
                <input type="password" class="form-control" id="password" name="password" placeholder="Password">
              </div>
            </div>
            <div class="form-group">
                <div class="col-lg-10 col-lg-offset-5">
                    <button type="submit" name="submit" class="btn btn-primary">Submit</button>
                    <button type="reset" class="btn btn-default">Cancel</button>
                </div>
            </div>
      </div>
    </fieldset>
</form>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery-1.11.2.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>