<?php 
//error_reporting(0);
define('INCLUDE_CHECK',true);
session_start();
session_destroy();
require 'classes/config1.php';

$msg="";
if(isset($_POST['login'])){
	$email = htmlspecialchars($_POST['email']);
	$password = htmlspecialchars($_POST['password']);
	$sql=("SELECT * FROM admins_account WHERE username='$email' AND password='$password' AND status='active' OR email='$email' AND password='$password' AND status='active'");
	$result = $conn->query($sql);
			if ($result->num_rows > 0) {
            	while($row = $result->fetch_assoc()) {
				$_SESSION['id']= $row['id'];
			//	$_SESSION['email'] = $row['email'];
				$_SESSION['username'] = $row['username']; 
				$_SESSION['c'] = $row['c'];
                                $_SESSION['accessed_level'] = $row['accessed_Level'];
				$sqlupdate=("UPDATE admins_account SET is_online='yes' WHERE id='{$_SESSION['id']}'")or die ('An error occured ' . mysql_error());
			    $res = $conn->query($sqlupdate);
				if ($row['c']!=0){
				    
				    
					header("location: dashboard.php?action=home");
				}else{
					header("location: dashboard.php?action=administrator_setup");
				}
				exit(); 
				
		}
		}else{
			$msg ="<div class=bg-warning>Invalid Username/Password</div>";
		}
}
$conn->close();
?>

<!DOCTYPE html>
<html lang="en">
	<head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title>OSCOTECH, ESA-OKE :: Admin-Dashboard Login</title>
        <link href="layout/css/default.css" rel="stylesheet">
</head>
  
<body>
	<div id="main">
		<div class="logo w"><img src="images/logo.png"></div>		
	</div>

<div class="content">
	<div class="content-mini">
			<div class="box_block">
				<div class="box">
							<img src="images/student.png">
				</div>					
				<div class="box ww" style="width: 342px;">
                    <div class="cvn">
                    <form name="login" method="post" action=""  id="login">
                    	<center>
                    		<?php echo $msg; ?>
                        </center>
                      <!--  <a id="HyperLink1" href="#"><img src="images/home.jpg"></a>--><br>
                        <label for="email">Email Address:</label>
                        <input style="padding: 8px; width: 90%;" name="email" id="email" type="text" autocomplete="off" required placeholder="Username">
                        <br>
                        <label for="password">Password:</label>
                        <input class="xlarge" style="padding: 8px; width: 90%;" name="password" id="password" type="password" placeholder="Password" required>
                        <div align="center">
                            <div class="loginbtn"><input class="button1 red" value="Login" type="submit" name="login"></div>
                            <p style="font-size:11px; color:#000 !important;"><a href="#">Request a Password Reset</a></p>
                        </div>
                    </form>
                    </div>
				</div><div class="clr">&nbsp;</div>